From: Sam Hartman Date: Fri, 30 Jun 2006 02:09:03 +0000 (+0000) Subject: Merge to trunk rev 18278 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4db47580f9662884f534918d39d24610997d4fa;p=thirdparty%2Fkrb5.git Merge to trunk rev 18278 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/ldap-integ@18279 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/doc/.Sanitize b/doc/.Sanitize deleted file mode 100644 index 89b441370e..0000000000 --- a/doc/.Sanitize +++ /dev/null @@ -1,46 +0,0 @@ -# Sanitize.in for Kerberos V5 - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -ChangeLog -HOW_TO_BUILD -INCOMPATIBILITY -Makefile -OS-notes -SOURCE-TREE -TREE-GRAPH -api -implement -install.texi -install.ps -kadmin -krb5-protocol -old-V4-docs -texinfo.tex - -Things-to-lose: - -Do-last: - -# End of file. diff --git a/doc/api/.Sanitize b/doc/api/.Sanitize deleted file mode 100644 index e778459b99..0000000000 --- a/doc/api/.Sanitize +++ /dev/null @@ -1,48 +0,0 @@ -# Sanitize.in for Kerberos V5 - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -ChangeLog -Makefile -ccache.tex -changebar.sty -errors.tex -fancyheadings.sty -fixunder.sty -free.tex -functions.sty -intro.tex -keytab.tex -krb5.tex -libdes.tex -libos.tex -library.tex -rcache.tex -tables.tex - -Things-to-lose: - -Do-last: - -# End of file. diff --git a/doc/implement/.Sanitize b/doc/implement/.Sanitize deleted file mode 100644 index 1847a88d15..0000000000 --- a/doc/implement/.Sanitize +++ /dev/null @@ -1,46 +0,0 @@ -# Sanitize.in for Kerberos V5 - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -ChangeLog -Makefile -ccache-i.tex -changebar.sty -cksum-i.tex -crc-32-i.tex -encrypt-i.tex -fancyheadings.sty -fixunder.sty -functions.sty -implement.tex -kdb-i.tex -keytab-i.tex -libos-i.tex -rcache-i.tex - -Things-to-lose: - -Do-last: - -# End of file. diff --git a/doc/kadmin/.Sanitize b/doc/kadmin/.Sanitize deleted file mode 100644 index 148fae1be5..0000000000 --- a/doc/kadmin/.Sanitize +++ /dev/null @@ -1,33 +0,0 @@ -# Sanitize.in for Kerberos V5 - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -kpasswd.protocol -kadmin.protocol - -Things-to-lose: - -Do-last: - -# End of file. diff --git a/doc/krb5-protocol/.Sanitize b/doc/krb5-protocol/.Sanitize deleted file mode 100644 index d37d1b7f16..0000000000 --- a/doc/krb5-protocol/.Sanitize +++ /dev/null @@ -1,35 +0,0 @@ -# Sanitize.in for Kerberos V5 - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -krb5.constants -rfc1510.errata -rfc1510.txt -3-des.txt - -Things-to-lose: - -Do-last: - -# End of file. diff --git a/doc/old-V4-docs/.Sanitize b/doc/old-V4-docs/.Sanitize deleted file mode 100644 index d36248c952..0000000000 --- a/doc/old-V4-docs/.Sanitize +++ /dev/null @@ -1,36 +0,0 @@ -# Sanitize.in for Kerberos V5 - -# Each directory to survive it's way into a release will need a file -# like this one called "./.Sanitize". All keyword lines must exist, -# and must exist in the order specified by this file. Each directory -# in the tree will be processed, top down, in the following order. - -# Hash started lines like this one are comments and will be deleted -# before anything else is done. Blank lines will also be squashed -# out. - -# The lines between the "Do-first:" line and the "Things-to-keep:" -# line are executed as a /bin/sh shell script before anything else is -# done in this - -Do-first: - -# All files listed between the "Things-to-keep:" line and the -# "Files-to-sed:" line will be kept. All other files will be removed. -# Directories listed in this section will have their own Sanitize -# called. Directories not listed will be removed in their entirety -# with rm -rf. - -Things-to-keep: - -README -installation.PS -installation.mss -operation.PS -operation.mss - -Things-to-lose: - -Do-last: - -# End of file. diff --git a/src/Makefile.in b/src/Makefile.in index 01c6928d16..423cca4c5f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -183,6 +183,7 @@ WINMAKEFILES=Makefile \ lib\des425\Makefile \ lib\gssapi\Makefile lib\gssapi\generic\Makefile \ lib\gssapi\krb5\Makefile lib\gssapi\mechglue\Makefile \ + lib\gssapi\spnego\Makefile \ lib\krb4\Makefile lib\krb5\Makefile \ lib\krb5\asn.1\Makefile lib\krb5\ccache\Makefile \ lib\krb5\ccache\ccapi\Makefile \ @@ -268,6 +269,8 @@ WINMAKEFILES=Makefile \ ##DOS## $(WCONFIG) config < $@.in > $@ ##DOS##lib\gssapi\mechglue\Makefile: lib\gssapi\mechglue\Makefile.in $(MKFDEP) ##DOS## $(WCONFIG) config < $@.in > $@ +##DOS##lib\gssapi\spnego\Makefile: lib\gssapi\spnego\Makefile.in $(MKFDEP) +##DOS## $(WCONFIG) config < $@.in > $@ ##DOS##lib\gssapi\krb5\Makefile: lib\gssapi\krb5\Makefile.in $(MKFDEP) ##DOS## $(WCONFIG) config < $@.in > $@ ##DOS##lib\krb4\Makefile: lib\krb4\Makefile.in $(MKFDEP) @@ -366,7 +369,7 @@ FILES= ./* \ lib/crypto/sha1/* lib/crypto/arcfour/* lib/crypto/md4/* \ lib/crypto/md5/* lib/crypto/yarrow/* \ lib/des425/* lib/gssapi/* lib/gssapi/generic/* lib/gssapi/krb5/* \ - lib/gssapi/mechglue/* lib/krb4/* \ + lib/gssapi/mechglue/* lib/gssapi/spnego/* lib/krb4/* \ lib/krb5/* lib/krb5/asn.1/* lib/krb5/krb/* \ lib/krb5/ccache/* lib/krb5/ccache/ccapi/* \ lib/krb5/error_tables/* \ @@ -408,7 +411,7 @@ ETOUT = \ $(GK)gssapi_err_krb5.h $(GK)gssapi_err_krb5.c \ lib/krb4/krb_err_txt.c -HOUT = $(INC)krb5.h $(GG)gssapi.h $(PR)profile.h +HOUT = $(INC)krb5\krb5.h $(GG)gssapi.h $(PR)profile.h CLEANUP= Makefile $(ETOUT) $(HOUT) \ include/profile.h include/osconf.h \ @@ -546,10 +549,12 @@ install-windows:: @if not exist "$(KRB_INSTALL_DIR)\$(NULL)" @echo The directory $(KRB_INSTALL_DIR) does not exist. Please create it. @if not exist "$(KRB_INSTALL_DIR)\$(NULL)" @dir /b $(KRB_INSTALL_DIR)\nul @if not exist "$(KRB_INSTALL_DIR)\include\$(NULL)" @mkdir "$(KRB_INSTALL_DIR)\include" + @if not exist "$(KRB_INSTALL_DIR)\include\krb5\$(NULL)" @mkdir "$(KRB_INSTALL_DIR)\include\krb5" @if not exist "$(KRB_INSTALL_DIR)\include\gssapi\$(NULL)" @mkdir "$(KRB_INSTALL_DIR)\include\gssapi" @if not exist "$(KRB_INSTALL_DIR)\lib\$(NULL)" @mkdir "$(KRB_INSTALL_DIR)\lib" @if not exist "$(KRB_INSTALL_DIR)\bin\$(NULL)" @mkdir "$(KRB_INSTALL_DIR)\bin" $(CP) include\krb5.h "$(KRB_INSTALL_DIR)\include\." + $(CP) include\krb5\krb5.h "$(KRB_INSTALL_DIR)\include\krb5\." $(CP) include\win-mac.h "$(KRB_INSTALL_DIR)\include\." $(CP) include\profile.h "$(KRB_INSTALL_DIR)\include\." $(CP) include\com_err.h "$(KRB_INSTALL_DIR)\include\." diff --git a/src/appl/bsd/krlogin.c b/src/appl/bsd/krlogin.c index a1e63a6450..05913f6075 100644 --- a/src/appl/bsd/krlogin.c +++ b/src/appl/bsd/krlogin.c @@ -1101,7 +1101,7 @@ static void writer() for (;;) { FD_ZERO(&waitread); FD_SET(0, &waitread); - n = select(8*sizeof(waitread), &waitread, 0, 0, 0, 0); + n = select(1, &waitread, 0, 0, 0, 0); if (n < 0 && errno == EINTR) continue; if (n > 0) diff --git a/src/appl/bsd/krlogind.c b/src/appl/bsd/krlogind.c index 02bed8e370..8387f18dbf 100644 --- a/src/appl/bsd/krlogind.c +++ b/src/appl/bsd/krlogind.c @@ -1045,7 +1045,7 @@ void protocol(f, p) } } - if (select(8*sizeof(ibits), &ibits, &obits, &ebits, 0) < 0) { + if (select(((p > f) ? p : f) + 1, &ibits, &obits, &ebits, 0) < 0) { if (errno == EINTR) continue; fatalperror(f, "select"); diff --git a/src/appl/bsd/krsh.c b/src/appl/bsd/krsh.c index 08b68fef11..155223fab8 100644 --- a/src/appl/bsd/krsh.c +++ b/src/appl/bsd/krsh.c @@ -512,7 +512,7 @@ main(argc, argv0) rewrite: FD_ZERO(&rembits); FD_SET(rem, &rembits); - if (select(8*sizeof(rembits), 0, &rembits, 0, 0) < 0) { + if (select(rem + 1, 0, &rembits, 0, 0) < 0) { if (errno != EINTR) { perror("select"); exit(1); @@ -550,7 +550,7 @@ main(argc, argv0) FD_SET(rem, &readfrom); do { ready = readfrom; - if (select(8*sizeof(ready), &ready, 0, 0, 0) < 0) { + if (select(((rfd2 > rem) ? rfd2 : rem) + 1, &ready, 0, 0, 0) < 0) { if (errno != EINTR) { perror("select"); exit(1); diff --git a/src/appl/bsd/krshd.c b/src/appl/bsd/krshd.c index 808adf5d53..02ab132354 100644 --- a/src/appl/bsd/krshd.c +++ b/src/appl/bsd/krshd.c @@ -440,6 +440,22 @@ int main(argc, argv) fd = 0; } +/* + * AIX passes an IPv4-mapped IPv6 address back from getpeername, but if + * that address is later used in connect(), it returns an error. Convert + * IPv4-mapped IPv6 addresses to simple IPv4 addresses on AIX (but don't + * do this everywhere since it isn't always the right thing to do, just + * the least wrong on AIX). + */ +#if defined(_AIX) && defined(KRB5_USE_INET6) + if (((struct sockaddr*)&from)->sa_family == AF_INET6 && IN6_IS_ADDR_V4MAPPED(&sa2sin6(&from)->sin6_addr)) { + sa2sin(&from)->sin_len = sizeof(struct sockaddr_in); + sa2sin(&from)->sin_family = AF_INET; + sa2sin(&from)->sin_port = sa2sin6(&from)->sin6_port; + memmove(&(sa2sin(&from)->sin_addr.s_addr), &(sa2sin6(&from)->sin6_addr.u6_addr.u6_addr8[12]), 4); + } +#endif + if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&on, sizeof (on)) < 0) syslog(LOG_WARNING, "setsockopt (SO_KEEPALIVE): %m"); @@ -1198,6 +1214,7 @@ void doit(f, fromp) goto signout_please; } if (pid) { + int maxfd; #ifdef POSIX_SIGNALS sa.sa_handler = cleanup; (void)sigaction(SIGINT, &sa, (struct sigaction *)0); @@ -1231,11 +1248,18 @@ void doit(f, fromp) FD_ZERO(&readfrom); FD_SET(f, &readfrom); + maxfd = f; if(port) { FD_SET(s, &readfrom); + if (s > maxfd) + maxfd = s; FD_SET(pv[0], &readfrom); + if (pv[0] > maxfd) + maxfd = pv[0]; } FD_SET(pw[0], &readfrom); + if (pw[0] > maxfd) + maxfd = pw[0]; /* read from f, write to px[1] -- child stdin */ /* read from s, signal child */ @@ -1244,7 +1268,7 @@ void doit(f, fromp) do { ready = readfrom; - if (select(8*sizeof(ready), &ready, (fd_set *)0, + if (select(maxfd + 1, &ready, (fd_set *)0, (fd_set *)0, (struct timeval *)0) < 0) { if (errno == EINTR) { continue; diff --git a/src/appl/bsd/login.c b/src/appl/bsd/login.c index b49bababb7..a3cdef797c 100644 --- a/src/appl/bsd/login.c +++ b/src/appl/bsd/login.c @@ -786,7 +786,7 @@ static int verify_krb_v4_tgt (realm) struct hostent *hp; KTEXT_ST ticket; AUTH_DAT authdata; - unsigned long addr; + unsigned KRB4_32 addr; static /*const*/ char rcmd_str[] = "rcmd"; #if 0 char key[8]; diff --git a/src/appl/gssftp/ftp/Makefile.in b/src/appl/gssftp/ftp/Makefile.in index 5124834699..ded4c95dad 100644 --- a/src/appl/gssftp/ftp/Makefile.in +++ b/src/appl/gssftp/ftp/Makefile.in @@ -5,7 +5,7 @@ BUILDTOP=$(REL)..$(S)..$(S).. # # appl/gssftp/ftp/Makefile.in # -DEFINES = -DGSSAPI -DFTP_BUFSIZ=10240 +DEFINES = -DGSSAPI -DFTP_BUFSIZ=65535 PROG_LIBPATH=-L$(TOPLIBD) PROG_RPATH=$(KRB5_LIBDIR) diff --git a/src/appl/gssftp/ftp/cmds.c b/src/appl/gssftp/ftp/cmds.c index b9cb2a2a2c..3d851937b9 100644 --- a/src/appl/gssftp/ftp/cmds.c +++ b/src/appl/gssftp/ftp/cmds.c @@ -725,14 +725,14 @@ void mput(argc, argv) if (mflag && confirm(argv[0], cp)) { tp = cp; if (mcase) { - while (*tp && !islower((int) (*tp))) { + while (*tp && !islower((unsigned char) (*tp))) { tp++; } if (!*tp) { tp = cp; tp2 = tmpbuf; while ((*tp2 = *tp) != 0) { - if (isupper((int) *tp2)) { + if (isupper((unsigned char) *tp2)) { *tp2 = 'a' + *tp2 - 'A'; } tp++; @@ -864,14 +864,14 @@ usage: if (loc && mcase) { char *tp = argv[1], *tp2, tmpbuf[MAXPATHLEN]; - while (*tp && !islower((int) *tp)) { + while (*tp && !islower((unsigned char) *tp)) { tp++; } if (!*tp) { tp = argv[2]; tp2 = tmpbuf; while ((*tp2 = *tp) != 0) { - if (isupper((int) *tp2)) { + if (isupper((unsigned char) *tp2)) { *tp2 = 'a' + *tp2 - 'A'; } tp++; @@ -994,14 +994,14 @@ void mget(argc, argv) if (mflag && confirm(argv[0], cp)) { tp = cp; if (mcase) { - while (*tp && !islower((int) *tp)) { + while (*tp && !islower((unsigned char) *tp)) { tp++; } if (!*tp) { tp = cp; tp2 = tmpbuf; while ((*tp2 = *tp) != 0) { - if (isupper((int) *tp2)) { + if (isupper((unsigned char) *tp2)) { *tp2 = 'a' + *tp2 - 'A'; } tp++; diff --git a/src/appl/gssftp/ftpd/ftpcmd.y b/src/appl/gssftp/ftpd/ftpcmd.y index 096014bd22..30bced06a8 100644 --- a/src/appl/gssftp/ftpd/ftpcmd.y +++ b/src/appl/gssftp/ftpd/ftpcmd.y @@ -971,7 +971,7 @@ urgsafe_getc(f) * getline - a hacked up version of fgets to ignore TELNET escape codes. */ char * -getline(s, n, iop) +ftpd_getline(s, n, iop) char *s; int n; register FILE *iop; @@ -1213,7 +1213,7 @@ yylex() case CMD: (void) signal(SIGALRM, toolong); (void) alarm((unsigned) timeout); - if (getline(cbuf, sizeof(cbuf)-1, stdin) == NULL) { + if (ftpd_getline(cbuf, sizeof(cbuf)-1, stdin) == NULL) { reply(221, "You could at least say goodbye."); dologout(0); } diff --git a/src/appl/gssftp/ftpd/ftpd.c b/src/appl/gssftp/ftpd/ftpd.c index 6655e0d62a..71744a57f8 100644 --- a/src/appl/gssftp/ftpd/ftpd.c +++ b/src/appl/gssftp/ftpd/ftpd.c @@ -176,7 +176,6 @@ extern char version[]; extern char *home; /* pointer to home directory for glob */ extern FILE *ftpd_popen(), *fopen(), *freopen(); extern int ftpd_pclose(), fclose(); -extern char *getline(); extern char cbuf[]; extern off_t restart_point; @@ -2139,7 +2138,7 @@ myoob(sig) if (!transflag) return; cp = tmpline; - if (getline(cp, sizeof(tmpline), stdin) == NULL) { + if (ftpd_getline(cp, sizeof(tmpline), stdin) == NULL) { reply(221, "You could at least say goodbye."); dologout(0); } diff --git a/src/appl/gssftp/ftpd/ftpd_var.h b/src/appl/gssftp/ftpd/ftpd_var.h index 07fb14a637..8d833e4ec9 100644 --- a/src/appl/gssftp/ftpd/ftpd_var.h +++ b/src/appl/gssftp/ftpd/ftpd_var.h @@ -89,7 +89,7 @@ extern void lreply(int, char *, ...) /* ftpcmd.y */ void upper(char *); -char *getline(char *, int, FILE *); +char *ftpd_getline(char *, int, FILE *); #endif /* FTPD_VAR_H__ */ /* popen.c */ diff --git a/src/appl/libpty/Makefile.in b/src/appl/libpty/Makefile.in index 3c3ca3828d..2e8c8dad7f 100644 --- a/src/appl/libpty/Makefile.in +++ b/src/appl/libpty/Makefile.in @@ -107,8 +107,8 @@ $(BUILDTOP)/include/autoconf.h: $(SRCTOP)/include/autoconf.h.in (cd $(BUILDTOP)/include; $(MAKE) autoconf.h) -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/appl/libpty/configure.in b/src/appl/libpty/configure.in index f8930d0e27..cb5fe7e718 100644 --- a/src/appl/libpty/configure.in +++ b/src/appl/libpty/configure.in @@ -63,7 +63,7 @@ AC_CHECK_HEADER(sys/ptyvar.h, [], [], # AC_CHECK_HEADERS(utmp.h utmpx.h) -AC_CHECK_FUNCS(setutent setutxent updwtmp updwtmpx logwtmp getutmp getutmpx) +AC_CHECK_FUNCS(setutent setutxent setutsent updwtmp updwtmpx logwtmp getutmp getutmpx) AC_CHECK_FUNCS(utmpname utmpxname) AC_DEFUN(K5_CHECK_UT_MEMBER, diff --git a/src/appl/libpty/update_utmp.c b/src/appl/libpty/update_utmp.c index 004582650a..d2de6428f6 100644 --- a/src/appl/libpty/update_utmp.c +++ b/src/appl/libpty/update_utmp.c @@ -252,6 +252,14 @@ * * There is no wtmpx file, despite there being utmp and utmpx files. * + * HP-UX 11.23: + * + * In addition to other HP-UX issues, 11.23 includes yet another utmp + * management interface in utmps.h. This interface updates a umtpd + * daemon which then manages local files. Directly accessing the files + * through the existing, yet deprecated, utmp.h interface results in + * nothing. + * * Irix 6.x: * * In utmpx, ut_exit contains __e_termination and __e_exit, which get @@ -324,10 +332,19 @@ /* * The following grossness exists to avoid duplicating lots of code * between the cases where we have an old-style sysV utmp and where we - * have a modern (Unix98 or XPG4) utmpx. See the above history rant - * for further explanation. + * have a modern (Unix98 or XPG4) utmpx, or the new (hp-ux 11.23) utmps. + * See the above history rant for further explanation. */ -#if defined(HAVE_SETUTXENT) || defined(HAVE_SETUTENT) +#if defined(HAVE_SETUTXENT) || defined(HAVE_SETUTENT) || defined(HAVE_SETUTSENT) +#ifdef HAVE_SETUTSENT +#include +#define PTY_STRUCT_UTMPX struct utmps +#define PTY_SETUTXENT setutsent +#define PTY_GETUTXENT GETUTSENT +#define PTY_GETUTXLINE GETUTSLINE +#define PTY_PUTUTXLINE PUTUTSLINE +#define PTY_ENDUTXENT endutsent +#else #ifdef HAVE_SETUTXENT #define PTY_STRUCT_UTMPX struct utmpx #define PTY_SETUTXENT setutxent @@ -343,7 +360,7 @@ #define PTY_PUTUTXLINE pututline #define PTY_ENDUTXENT endutent #endif - +#endif static int better(const PTY_STRUCT_UTMPX *, const PTY_STRUCT_UTMPX *, const PTY_STRUCT_UTMPX *); static int match_pid(const PTY_STRUCT_UTMPX *, diff --git a/src/appl/telnet/libtelnet/Makefile.4.4 b/src/appl/telnet/libtelnet/Makefile.4.4 deleted file mode 100644 index 495dd73c5b..0000000000 --- a/src/appl/telnet/libtelnet/Makefile.4.4 +++ /dev/null @@ -1,33 +0,0 @@ -# @(#)Makefile 8.2 (Berkeley) 12/15/93 - -LIB= telnet -SRCS= auth.c encrypt.c genget.c getent.c misc.c -SRCS+= kerberos.c enc_des.c -#SRCS+= kerberos5.c -CFLAGS+= -DENCRYPTION -DAUTHENTICATION -DHAS_CGETENT -CFLAGS+= -DKRB4 -DDES_ENCRYPTION -I/usr/include/kerberosIV - -# These are the sources that have encryption stuff in them. -CRYPT_SRC= auth.c enc-proto.h enc_des.c encrypt.c -CRYPT_SRC+= encrypt.h kerberos.c kerberos5.c krb4encpwd.c -CRYPT_SRC+= misc.c spx.c Makefile -NOCRYPT_DIR=${.CURDIR}/Nocrypt - -.include - -nocrypt: -#ifdef ENCRYPTION - @for i in ${CRYPT_SRC}; do \ - if [ ! -d ${NOCRYPT_DIR} ]; then \ - echo Creating subdirectory ${NOCRYPT_DIR}; \ - mkdir ${NOCRYPT_DIR}; \ - fi; \ - echo ${NOCRYPT_DIR}/$$i; \ - unifdef -UENCRYPTION ${.CURDIR}/$$i | \ - sed "s/ || defined(ENCRYPTION)//" > ${NOCRYPT_DIR}/$$i; \ - done - -placeholder: -#else /* ENCRYPTION */ - @echo "Encryption code already removed." -#endif /* ENCRYPTION */ diff --git a/src/appl/telnet/libtelnet/Makefile.generic b/src/appl/telnet/libtelnet/Makefile.generic deleted file mode 100644 index 760417f17e..0000000000 --- a/src/appl/telnet/libtelnet/Makefile.generic +++ /dev/null @@ -1,67 +0,0 @@ -# -# Copyright (c) 1991 The Regents of the University of California. -# All rights reserved. -# -# Redistribution and use in source and binary forms are permitted provided -# that: (1) source distributions retain this entire copyright notice and -# comment, and (2) distributions including binaries display the following -# acknowledgement: ``This product includes software developed by the -# University of California, Berkeley and its contributors'' in the -# documentation or other materials provided with the distribution and in -# all advertising materials mentioning features or use of this software. -# 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 WITHOUT ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -# -# @(#)Makefile.generic 5.5 (Berkeley) 3/1/91 -# - -LIB= libtelnet.a -SRCS= auth.c encrypt.c genget.c \ - misc.c kerberos.c kerberos5.c forward.c spx.c enc_des.c \ - rsaencpwd.c krb4encpwd.c read_password.c \ - setenv.c getent.c strdup.c strcasecmp.c \ - strchr.c strrchr.c strftime.c strerror.c \ - ${LIB_SRC} - -OBJS= auth.o encrypt.o genget.o \ - misc.o kerberos.o kerberos5.o forward.o spx.o enc_des.o \ - rsaencpwd.o krb4encpwd.o read_password.o \ - ${LIB_OBJ} - -TELNET_H= ../arpa/telnet.h - -CFLAGS= ${LCCFLAGS} ${DEFINES} ${INCLUDES} - -${LIB}: ${OBJS} - rm -f ${LIB} - ${AR} ${ARFLAGS} ${LIB} `lorder ${OBJS} | tsort` - @if [ ${RANLIB} != NONE ]; \ - then echo ${RANLIB} ${LIB}; ${RANLIB} ${LIB}; fi - -clean cleandir: - rm -f *.o ${LIB} core a.out - -auth.o: ${TELNET_H} -auth.o: encrypt.h -auth.o: auth.h -auth.o: misc-proto.h -encrypt.o: ${TELNET_H} -encrypt.o: encrypt.h -encrypt.o: misc.h -kerberos.o: ${TELNET_H} -kerberos.o: encrypt.h -kerberos.o: auth.h -kerberos.o: misc.h -kerberos5.o: ${TELNET_H} -kerberos5.o: encrypt.h -kerberos5.o: auth.h -kerberos5.o: misc.h -misc.o: misc.h -enc_des.o: ${TELNET_H} -enc_des.o: encrypt.h -enc_des.o: key-proto.h -enc_des.o: misc-proto.h diff --git a/src/appl/telnet/libtelnet/Makefile.in b/src/appl/telnet/libtelnet/Makefile.in index aec819d732..2a6c7dc517 100644 --- a/src/appl/telnet/libtelnet/Makefile.in +++ b/src/appl/telnet/libtelnet/Makefile.in @@ -26,7 +26,7 @@ BUILDTOP=$(REL)..$(S)..$(S).. AUTH_DEF=-DAUTHENTICATION -DENCRYPTION -DDES_ENCRYPTION -DKRB5 -DFORWARD \ -UNO_LOGIN_F -DLOGIN_CAP_F -DLOGIN_PROGRAM=KRB5_PATH_LOGIN LOCALINCLUDES=-I.. -I$(srcdir)/.. @KRB4_INCLUDES@ -DEFINES = $(AUTH_DEF) +DEFINES = -DTELNET_BUFSIZE=65535 $(AUTH_DEF) LIBOBJS=@LIBOBJS@ SETENVSRC=@SETENVSRC@ @@ -89,8 +89,8 @@ enc_des.o: key-proto.h enc_des.o: misc-proto.h install:: -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/appl/telnet/libtelnet/kerberos5.c b/src/appl/telnet/libtelnet/kerberos5.c index ad36aedda2..ab8e04d3c4 100644 --- a/src/appl/telnet/libtelnet/kerberos5.c +++ b/src/appl/telnet/libtelnet/kerberos5.c @@ -99,7 +99,7 @@ static void kerberos5_forward(Authenticator *); #endif /* FORWARD */ -static unsigned char str_data[8192] = {IAC, SB, TELOPT_AUTHENTICATION, 0, +static unsigned char str_data[TELNET_BUFSIZE] = {IAC, SB, TELOPT_AUTHENTICATION, 0, AUTHTYPE_KERBEROS_V5, }; /*static unsigned char str_name[1024] = { IAC, SB, TELOPT_AUTHENTICATION, TELQUAL_NAME, };*/ diff --git a/src/appl/telnet/telnet/Makefile.4.4 b/src/appl/telnet/telnet/Makefile.4.4 deleted file mode 100644 index 2e38a2880d..0000000000 --- a/src/appl/telnet/telnet/Makefile.4.4 +++ /dev/null @@ -1,73 +0,0 @@ -# -# Copyright (c) 1990 The Regents of the University of California. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the University of -# California, Berkeley and its contributors. -# 4. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. -# -# @(#)Makefile 8.1 (Berkeley) 6/6/93 -# - -PROG= telnet - -CFLAGS+=-DTERMCAP -DKLUDGELINEMODE -DUSE_TERMIO -DAUTHENTICATION -DENCRYPTION -CFLAGS+=-DENV_HACK -CFLAGS+=-I${.CURDIR}/../../lib - -CFLAGS+= -DKRB4 - -LDADD= -ltermcap -ltelnet -LDADD+= -lkrb -ldes -DPADD= ${LIBTERMCAP} - -SRCS= authenc.c commands.c main.c network.c ring.c sys_bsd.c telnet.c \ - terminal.c tn3270.c utilities.c - -# These are the sources that have encryption stuff in them. -CRYPT_SRC= authenc.c commands.c externs.h main.c network.c -CRYPT_SRC+= ring.c ring.h telnet.c terminal.c utilities.c Makefile -NOCRYPT_DIR=${.CURDIR}/Nocrypt - -.include - -nocrypt: -#ifdef ENCRYPTION - @for i in ${CRYPT_SRC}; do \ - if [ ! -d ${NOCRYPT_DIR} ]; then \ - echo Creating subdirectory ${NOCRYPT_DIR}; \ - mkdir ${NOCRYPT_DIR}; \ - fi; \ - echo ${NOCRYPT_DIR}/$$i; \ - unifdef -UENCRYPTION ${.CURDIR}/$$i | \ - sed "s/ || defined(ENCRYPTION)//" > ${NOCRYPT_DIR}/$$i; \ - done - -placeholder: -#else /* ENCRYPTION */ - @echo "Encryption code already removed." -#endif /* ENCRYPTION */ diff --git a/src/appl/telnet/telnet/Makefile.generic b/src/appl/telnet/telnet/Makefile.generic deleted file mode 100644 index 5b6ea26518..0000000000 --- a/src/appl/telnet/telnet/Makefile.generic +++ /dev/null @@ -1,89 +0,0 @@ -# -# Copyright (c) 1991 The Regents of the University of California. -# All rights reserved. -# -# Redistribution and use in source and binary forms are permitted provided -# that: (1) source distributions retain this entire copyright notice and -# comment, and (2) distributions including binaries display the following -# acknowledgement: ``This product includes software developed by the -# University of California, Berkeley and its contributors'' in the -# documentation or other materials provided with the distribution and in -# all advertising materials mentioning features or use of this software. -# 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 WITHOUT ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -# -# @(#)Makefile.generic 5.5 (Berkeley) 3/1/91 -# - -INCLUDES= -I.. -ARPA_TELNET= ../arpa/telnet.h - -SRCS= commands.c main.c network.c ring.c \ - sys_bsd.c telnet.c terminal.c \ - utilities.c ${GETOPT_SRC} - -CFLAGS= ${LCCFLAGS} ${INCLUDES} ${DEFINES} - -ALLHC= ${SRCS} \ - defines.h externs.h fdset.h general.h \ - ring.h types.h - -OBJS= authenc.o commands.o main.o network.o ring.o sys_bsd.o \ - telnet.o terminal.o utilities.o ${GETOPT_OBJ} -MAN= telnet.0 - -# -# These next three lines are not needed in 4.4BSD -# -.SUFFIXES: .0 .1 -.1.0: - nroff -man -h $< > $@ - -all: telnet - -telnet: ${OBJS} ${LIBPATH} - ${CC} -o $@ ${CFLAGS} ${OBJS} ${LIBS} - -clean: FRC - rm -f ${OBJS} core errs l.errs telnet - -cleandir: clean - rm -f ${MAN} tags .depend - -clist: FRC ${SRCS} - @for i in ${SRCS} ; \ - do (echo ${DIRPATH}$$i); done - -hclist: FRC ${ALLHC} - @for i in ${ALLHC} ; \ - do (echo ${DIRPATH}$$i); done - -depend: FRC ${SRCS} - mkdep ${CFLAGS} `make clist` - -install: ${MAN} FRC - install -s -o bin -g bin -m 755 telnet ${DEST} - install -c -o bin -g bin -m 444 telnet.0 ${DESTDIR}/usr/man/cat1 - -lint: FRC ${SRCS} - lint ${CFLAGS} `make clist` - -tags: FRC ${SRCS} - ctags `make hclist` - -FRC: - -authenc.o: defines.h externs.h general.h ring.h types.h ${ARPA_TELNET} -commands.o: defines.h externs.h general.h ring.h types.h ${ARPA_TELNET} -main.o: defines.h externs.h ring.h -network.o: defines.h externs.h fdset.h ring.h ${ARPA_TELNET} -ring.o: general.h ring.h -sys_bsd.o: defines.h externs.h fdset.h ring.h types.h ${ARPA_TELNET} -telnet.o: defines.h externs.h general.h ring.h types.h ${ARPA_TELNET} -terminal.o: externs.h ring.h types.h ${ARPA_TELNET} -tn3270.o: defines.h externs.h fdset.h general.h ring.h ${ARPA_TELNET} -utilities.o: defines.h externs.h fdset.h general.h ring.h ${ARPA_TELNET} diff --git a/src/appl/telnet/telnet/Makefile.in b/src/appl/telnet/telnet/Makefile.in index 5e7b6c028d..42a0578999 100644 --- a/src/appl/telnet/telnet/Makefile.in +++ b/src/appl/telnet/telnet/Makefile.in @@ -27,7 +27,7 @@ BUILDTOP=$(REL)..$(S)..$(S).. AUTH_DEF=-DAUTHENTICATION -DENCRYPTION -DKRB5 -DFORWARD -UNO_LOGIN_F -DLOGIN_CAP_F -DLOGIN_PROGRAM=KRB5_PATH_LOGIN OTHERDEFS=-DLINEMODE -DKLUDGELINEMODE -DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON LOCALINCLUDES=-I.. -I$(srcdir)/.. -DEFINES = $(AUTH_DEF) $(OTHERDEFS) +DEFINES = -DTELNET_BUFSIZE=65535 $(AUTH_DEF) $(OTHERDEFS) ARPA_TELNET= $(srcdir)/../arpa/telnet.h PROG_LIBPATH=-L$(TOPLIBD) diff --git a/src/appl/telnet/telnet/network.c b/src/appl/telnet/telnet/network.c index 1282bdb7ee..60dc3bdcf6 100644 --- a/src/appl/telnet/telnet/network.c +++ b/src/appl/telnet/telnet/network.c @@ -52,7 +52,7 @@ #include "fdset.h" Ring netoring, netiring; -unsigned char netobuf[2*BUFSIZ], netibuf[BUFSIZ]; +unsigned char netobuf[2*TELNET_BUFSIZE], netibuf[TELNET_BUFSIZE]; /* * Initialize internal network data structures. diff --git a/src/appl/telnet/telnet/telnet.c b/src/appl/telnet/telnet/telnet.c index 6215fc1e9b..a44df7ab53 100644 --- a/src/appl/telnet/telnet/telnet.c +++ b/src/appl/telnet/telnet/telnet.c @@ -717,8 +717,8 @@ mklist(buf, name) */ if ((c == ' ') || !isascii(c)) n = 1; - else if (islower((int) c)) - *cp = toupper((int) c); + else if (islower((unsigned char) c)) + *cp = toupper((unsigned char) c); } /* diff --git a/src/appl/telnet/telnetd/Makefile.4.4 b/src/appl/telnet/telnetd/Makefile.4.4 deleted file mode 100644 index 4b1d5302e6..0000000000 --- a/src/appl/telnet/telnetd/Makefile.4.4 +++ /dev/null @@ -1,36 +0,0 @@ -# @(#)Makefile 8.2 (Berkeley) 12/15/93 - -PROG= telnetd -CFLAGS+=-DLINEMODE -DKLUDGELINEMODE -DUSE_TERMIO -DDIAGNOSTICS -CFLAGS+=-DOLD_ENVIRON -DENV_HACK -CFLAGS+=-DAUTHENTICATION -DENCRYPTION -I${.CURDIR}/../../lib -SRCS= authenc.c global.c slc.c state.c sys_term.c telnetd.c \ - termstat.c utility.c -DPADD= ${LIBUTIL} ${LIBTERM} -LDADD= -lutil -ltermcap -ltelnet -LDADD+= -lkrb -ldes -MAN8= telnetd.0 - -# These are the sources that have encryption stuff in them. -CRYPT_SRC= authenc.c ext.h state.c telnetd.c termstat.c -CRYPT_SRC+= utility.c Makefile -NOCRYPT_DIR=${.CURDIR}/Nocrypt - -.include - -nocrypt: -#ifdef ENCRYPTION - @for i in ${CRYPT_SRC}; do \ - if [ ! -d ${NOCRYPT_DIR} ]; then \ - echo Creating subdirectory ${NOCRYPT_DIR}; \ - mkdir ${NOCRYPT_DIR}; \ - fi; \ - echo ${NOCRYPT_DIR}/$$i; \ - unifdef -UENCRYPTION ${.CURDIR}/$$i | \ - sed "s/ || defined(ENCRYPTION)//" > ${NOCRYPT_DIR}/$$i; \ - done - -placeholder: -#else /* ENCRYPTION */ - @echo "Encryption code already removed." -#endif /* ENCRYPTION */ diff --git a/src/appl/telnet/telnetd/Makefile.generic b/src/appl/telnet/telnetd/Makefile.generic deleted file mode 100644 index 8920429732..0000000000 --- a/src/appl/telnet/telnetd/Makefile.generic +++ /dev/null @@ -1,71 +0,0 @@ -# -# Copyright (c) 1991 The Regents of the University of California. -# All rights reserved. -# -# Redistribution and use in source and binary forms are permitted provided -# that: (1) source distributions retain this entire copyright notice and -# comment, and (2) distributions including binaries display the following -# acknowledgement: ``This product includes software developed by the -# University of California, Berkeley and its contributors'' in the -# documentation or other materials provided with the distribution and in -# all advertising materials mentioning features or use of this software. -# 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 WITHOUT ANY EXPRESS OR IMPLIED -# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -# -# @(#)Makefile.generic 5.5 (Berkeley) 3/1/91 -# - -SRC1= telnetd.c state.c termstat.c slc.c sys_term.c utility.c global.c authenc.c -OBJ1= telnetd.o state.o termstat.o slc.o sys_term.o utility.o global.o authenc.o - -OBJS= ${OBJ1} ${GETTYOBJ} -SRCS= ${SRC1} ${GETTYSRC} - -MAN= telnetd.0 -CFLAGS= ${LCCFLAGS} ${INCLUDES} ${DEFINES} -ARPA_TELNET = ../arpa/telnet.h - -# -# These next three lines are not needed in 4.4BSD -# -.SUFFIXES: .0 .8 -.8.0: - nroff -man -h $< > $@ - - -all: telnetd - -telnetd: ${OBJS} ${LIBPATH} - ${CC} -o $@ ${CFLAGS} ${OBJS} ${LIBS} - -clean: - rm -f ${OBJS} core telnetd - -cleandir: clean - rm -f ${MAN} tags .depend - -depend: ${SRCS} - mkdep ${CFLAGS} ${SRCS} - -install: ${MAN} - install -s -o bin -g bin -m 755 telnetd ${LIBEXEC} - install -c -o bin -g bin -m 444 ${MAN} ${DESTDIR}/usr/man/cat8 - -lint: ${SRCS} - lint ${CFLAGS} ${SRCS} - -tags: ${SRCS} - ctags ${SRCS} - -authenc.o: telnetd.h -global.o: defs.h ext.h ${ARPA_TELNET} -slc.o: telnetd.h defs.h ext.h ${ARPA_TELNET} -state.o: telnetd.h defs.h ext.h ${ARPA_TELNET} -sys_term.o: telnetd.h pathnames.h defs.h ext.h ${ARPA_TELNET} -telnetd.o: telnetd.h defs.h ext.h ${ARPA_TELNET} -termstat.o: telnetd.h defs.h ext.h ${ARPA_TELNET} -utility.o: telnetd.h defs.h ext.h ${ARPA_TELNET} diff --git a/src/appl/telnet/telnetd/Makefile.in b/src/appl/telnet/telnetd/Makefile.in index c1368629bd..0b19dd3698 100644 --- a/src/appl/telnet/telnetd/Makefile.in +++ b/src/appl/telnet/telnetd/Makefile.in @@ -27,7 +27,7 @@ BUILDTOP=$(REL)..$(S)..$(S).. AUTH_DEF=-DAUTHENTICATION -DENCRYPTION -DKRB5 -DFORWARD -UNO_LOGIN_F -ULOGIN_CAP_F -DLOGIN_PROGRAM=KRB5_PATH_LOGIN OTHERDEFS=-DKLUDGELINEMODE -DDIAGNOSTICS -DENV_HACK -DOLD_ENVIRON LOCALINCLUDES=-I.. -I$(srcdir)/.. -DEFINES = $(AUTH_DEF) $(OTHERDEFS) +DEFINES = -DTELNET_BUFSIZE=65535 $(AUTH_DEF) $(OTHERDEFS) ARPA_TELNET= $(srcdir)/../arpa/telnet.h PROG_LIBPATH=-L$(TOPLIBD) $(KRB4_LIBPATH) diff --git a/src/appl/telnet/telnetd/state.c b/src/appl/telnet/telnetd/state.c index b01842f006..e08c5bb13a 100644 --- a/src/appl/telnet/telnetd/state.c +++ b/src/appl/telnet/telnetd/state.c @@ -53,7 +53,7 @@ static int envvarok (char *); * Buffer for sub-options, and macros * for suboptions buffer manipulations */ -unsigned char subbuffer[4096], *subpointer= subbuffer, *subend= subbuffer; +unsigned char subbuffer[TELNET_BUFSIZE], *subpointer= subbuffer, *subend= subbuffer; #define SB_CLEAR() subpointer = subbuffer #define SB_TERM() { subend = subpointer; SB_CLEAR(); } diff --git a/src/config/config.guess b/src/config/config.guess index 500ee74b04..7924ac077d 100755 --- a/src/config/config.guess +++ b/src/config/config.guess @@ -1,9 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, +# Inc. -timestamp='2003-10-03' +timestamp='2006-06-06' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -17,13 +18,15 @@ timestamp='2003-10-03' # # 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. +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. + # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. @@ -53,7 +56,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO @@ -66,11 +69,11 @@ Try \`$me --help' for more information." while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; + echo "$timestamp" ; exit ;; --version | -v ) - echo "$version" ; exit 0 ;; + echo "$version" ; exit ;; --help | --h* | -h ) - echo "$usage"; exit 0 ;; + echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. @@ -104,7 +107,7 @@ set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; - { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; @@ -123,7 +126,7 @@ case $CC_FOR_BUILD,$HOST_CC,$CC in ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ;' +esac ; set_cc_for_build= ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) @@ -196,50 +199,32 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" - exit 0 ;; - amiga:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - hp300:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mac68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - macppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme68k:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvme88k:OpenBSD:*:*) - echo m88k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - mvmeppc:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sgi:OpenBSD:*:*) - echo mipseb-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - sun3:OpenBSD:*:*) - echo m68k-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; + exit ;; *:OpenBSD:*:*) - echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerppc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; alpha:OSF1:*:*) - if test $UNAME_RELEASE = "V4.0"; then + case $UNAME_RELEASE in + *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - fi + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU @@ -277,42 +262,49 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac + # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; - Alpha*:OpenVMS:*:*) - echo alpha-hp-vms - exit 0 ;; + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix - exit 0 ;; + exit ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 - exit 0 ;; + exit ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 - exit 0;; + exit ;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos - exit 0 ;; + exit ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos - exit 0 ;; + exit ;; *:OS/390:*:*) echo i370-ibm-openedition - exit 0 ;; + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} - exit 0;; + exit ;; + arm:riscos:*:*|arm:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp - exit 0;; + exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then @@ -320,32 +312,32 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in else echo pyramid-pyramid-bsd fi - exit 0 ;; + exit ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 - exit 0 ;; + exit ;; DRS?6000:unix:4.0:6*) echo sparc-icl-nx6 - exit 0 ;; - DRS?6000:UNIX_SV:4.2*:7*) + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) case `/usr/bin/uname -p` in - sparc) echo sparc-icl-nx7 && exit 0 ;; + sparc) echo sparc-icl-nx7; exit ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) @@ -354,10 +346,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` - exit 0 ;; + exit ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} - exit 0 ;; + exit ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 @@ -369,10 +361,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in echo sparc-sun-sunos${UNAME_RELEASE} ;; esac - exit 0 ;; + exit ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} - exit 0 ;; + exit ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor @@ -383,37 +375,40 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} - exit 0 ;; + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} - exit 0 ;; + exit ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 - exit 0 ;; + exit ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} - exit 0 ;; + exit ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} - exit 0 ;; + exit ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} - exit 0 ;; + exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c @@ -437,32 +432,33 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in exit (-1); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c \ - && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ - && exit 0 + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } echo mips-mips-riscos${UNAME_RELEASE} - exit 0 ;; + exit ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax - exit 0 ;; + exit ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax - exit 0 ;; + exit ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax - exit 0 ;; + exit ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix - exit 0 ;; + exit ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 - exit 0 ;; + exit ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 - exit 0 ;; + exit ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 - exit 0 ;; + exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` @@ -478,29 +474,29 @@ EOF else echo i586-dg-dgux${UNAME_RELEASE} fi - exit 0 ;; + exit ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 - exit 0 ;; + exit ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 - exit 0 ;; + exit ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 - exit 0 ;; + exit ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd - exit 0 ;; + exit ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` - exit 0 ;; + exit ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. - echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id - exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix - exit 0 ;; + exit ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` @@ -508,7 +504,7 @@ EOF IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} - exit 0 ;; + exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build @@ -523,14 +519,18 @@ EOF exit(0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 - echo rs6000-ibm-aix3.2.5 + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi - exit 0 ;; + exit ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then @@ -544,28 +544,28 @@ EOF IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} - exit 0 ;; + exit ;; *:AIX:*:*) echo rs6000-ibm-aix - exit 0 ;; + exit ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 - exit 0 ;; + exit ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to - exit 0 ;; # report: romp-ibm BSD 4.3 + exit ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx - exit 0 ;; + exit ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 - exit 0 ;; + exit ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd - exit 0 ;; + exit ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 - exit 0 ;; + exit ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in @@ -627,9 +627,19 @@ EOF esac if [ ${HP_ARCH} = "hppa2.0w" ] then - # avoid double evaluation of $set_cc_for_build - test -n "$CC_FOR_BUILD" || eval $set_cc_for_build - if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else @@ -637,11 +647,11 @@ EOF fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} - exit 0 ;; + exit ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} - exit 0 ;; + exit ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c @@ -669,153 +679,179 @@ EOF exit (0); } EOF - $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } echo unknown-hitachi-hiuxwe2 - exit 0 ;; + exit ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd - exit 0 ;; + exit ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd - exit 0 ;; + exit ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix - exit 0 ;; + exit ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf - exit 0 ;; + exit ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf - exit 0 ;; + exit ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi - exit 0 ;; + exit ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites - exit 0 ;; + exit ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd - exit 0 ;; + exit ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit 0 ;; + exit ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd - exit 0 ;; + exit ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd - exit 0 ;; + exit ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd - exit 0 ;; + exit ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + exit ;; *:UNICOS/mp:*:*) - echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' - exit 0 ;; + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" - exit 0 ;; + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} - exit 0 ;; + exit ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; + exit ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} - exit 0 ;; - *:FreeBSD:*:*|*:GNU/FreeBSD:*:*) - # Determine whether the default compiler uses glibc. - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #if __GLIBC__ >= 2 - LIBC=gnu - #else - LIBC= - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - # GNU/FreeBSD systems have a "k" prefix to indicate we are using - # FreeBSD's kernel, but not the complete OS. - case ${LIBC} in gnu) kernel_only='k' ;; esac - echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} - exit 0 ;; + exit ;; + *:FreeBSD:*:*) + case ${UNAME_MACHINE} in + pc98) + echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; + exit ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 - exit 0 ;; + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 - exit 0 ;; - x86:Interix*:[34]*) - echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//' - exit 0 ;; + exit ;; + x86:Interix*:[345]*) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + EM64T:Interix*:[345]*) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks - exit 0 ;; + exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix - exit 0 ;; + exit ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin - exit 0 ;; + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin - exit 0 ;; + exit ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` - exit 0 ;; + exit ;; *:GNU:*:*) + # the GNU system echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` - exit 0 ;; + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu + exit ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix - exit 0 ;; + exit ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; cris:Linux:*:*) echo cris-axis-linux-gnu - exit 0 ;; + exit ;; + crisv32:Linux:*:*) + echo crisv32-axis-linux-gnu + exit ;; + frv:Linux:*:*) + echo frv-unknown-linux-gnu + exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c @@ -832,8 +868,12 @@ EOF #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; mips64:Linux:*:*) eval $set_cc_for_build @@ -851,15 +891,22 @@ EOF #endif #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` - test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^CPU/{ + s: ::g + p + }'`" + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; + or32:Linux:*:*) + echo or32-unknown-linux-gnu + exit ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu - exit 0 ;; + exit ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu - exit 0 ;; + exit ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; @@ -873,7 +920,7 @@ EOF objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} - exit 0 ;; + exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in @@ -881,25 +928,28 @@ EOF PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac - exit 0 ;; + exit ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu - exit 0 ;; + exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux - exit 0 ;; + exit ;; sh64*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-gnu + exit ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu - exit 0 ;; + exit ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent @@ -917,15 +967,15 @@ EOF ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit 0 ;; + exit ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit 0 ;; + exit ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit 0 ;; + exit ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build @@ -942,7 +992,7 @@ EOF LIBC=gnulibc1 # endif #else - #ifdef __INTEL_COMPILER + #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) LIBC=gnu #else LIBC=gnuaout @@ -952,16 +1002,23 @@ EOF LIBC=dietlibc #endif EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 - test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' + /^LIBC/{ + s: ::g + p + }'`" + test x"${LIBC}" != x && { + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit + } + test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 - exit 0 ;; + exit ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... @@ -969,24 +1026,27 @@ EOF # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} - exit 0 ;; + exit ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx - exit 0 ;; + exit ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop - exit 0 ;; + exit ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos - exit 0 ;; + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp - exit 0 ;; + exit ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then @@ -994,15 +1054,16 @@ EOF else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi - exit 0 ;; - i*86:*:5:[78]*) + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} - exit 0 ;; + exit ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi - exit 0 ;; + exit ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv - exit 0 ;; + exit ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv - exit 0 ;; + exit ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix - exit 0 ;; - M68*:*:R3V[567]*:*) - test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ - && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ - && echo i486-ncr-sysv4 && exit 0 ;; + && { echo i486-ncr-sysv4; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 - exit 0 ;; + exit ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} - exit 0 ;; + exit ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} - exit 0 ;; + exit ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 - exit 0 ;; + exit ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 - exit 0 ;; + exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` @@ -1094,68 +1155,72 @@ EOF else echo ns32k-sni-sysv fi - exit 0 ;; + exit ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 - exit 0 ;; + exit ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 - exit 0 ;; + exit ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 - exit 0 ;; + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos - exit 0 ;; + exit ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} - exit 0 ;; + exit ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 - exit 0 ;; + exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi - exit 0 ;; + exit ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos - exit 0 ;; + exit ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos - exit 0 ;; + exit ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos - exit 0 ;; + exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} - exit 0 ;; + exit ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} - exit 0 ;; + exit ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} - exit 0 ;; + exit ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; + exit ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} - exit 0 ;; + exit ;; *:Darwin:*:*) - case `uname -p` in - *86) UNAME_PROCESSOR=i686 ;; - powerpc) UNAME_PROCESSOR=powerpc ;; + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} - exit 0 ;; + exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then @@ -1163,22 +1228,25 @@ EOF UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} - exit 0 ;; + exit ;; *:QNX:*:4*) echo i386-pc-qnx - exit 0 ;; - NSR-[DGKLNPTVWY]:NONSTOP_KERNEL:*:*) + exit ;; + NSE-?:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} - exit 0 ;; + exit ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux - exit 0 ;; + exit ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv - exit 0 ;; + exit ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} - exit 0 ;; + exit ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 @@ -1189,28 +1257,47 @@ EOF UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 - exit 0 ;; + exit ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 - exit 0 ;; + exit ;; *:TENEX:*:*) echo pdp10-unknown-tenex - exit 0 ;; + exit ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 - exit 0 ;; + exit ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 - exit 0 ;; + exit ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 - exit 0 ;; + exit ;; *:ITS:*:*) echo pdp10-unknown-its - exit 0 ;; + exit ;; SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} - exit 0 ;; + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 @@ -1242,7 +1329,7 @@ main () #endif #if defined (__arm) && defined (__acorn) && defined (__unix) - printf ("arm-acorn-riscix"); exit (0); + printf ("arm-acorn-riscix\n"); exit (0); #endif #if defined (hp300) && !defined (hpux) @@ -1331,11 +1418,12 @@ main () } EOF -$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 +$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } # Apollos put the system type in the environment. -test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; } # Convex versions that predate uname can use getsysinfo(1) @@ -1344,22 +1432,22 @@ then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd - exit 0 ;; + exit ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi - exit 0 ;; + exit ;; c34*) echo c34-convex-bsd - exit 0 ;; + exit ;; c38*) echo c38-convex-bsd - exit 0 ;; + exit ;; c4*) echo c4-convex-bsd - exit 0 ;; + exit ;; esac fi @@ -1370,7 +1458,9 @@ This script, last modified $timestamp, has failed to recognize the operating system you are using. It is advised that you download the most up to date version of the config scripts from - ftp://ftp.gnu.org/pub/gnu/config/ + http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess +and + http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub If the version you run ($0) is already up to date, please send the following data and any information you think might be diff --git a/src/config/config.sub b/src/config/config.sub index 1f31816b97..70584b007e 100755 --- a/src/config/config.sub +++ b/src/config/config.sub @@ -1,9 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, +# Inc. -timestamp='2003-08-18' +timestamp='2006-06-06' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -21,14 +22,15 @@ timestamp='2003-08-18' # # 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. - +# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA +# 02110-1301, USA. +# # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. + # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # @@ -70,7 +72,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO @@ -83,11 +85,11 @@ Try \`$me --help' for more information." while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) - echo "$timestamp" ; exit 0 ;; + echo "$timestamp" ; exit ;; --version | -v ) - echo "$version" ; exit 0 ;; + echo "$version" ; exit ;; --help | --h* | -h ) - echo "$usage"; exit 0 ;; + echo "$usage"; exit ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. @@ -99,7 +101,7 @@ while test $# -gt 0 ; do *local*) # First pass through any local machine types. echo $1 - exit 0;; + exit ;; * ) break ;; @@ -118,7 +120,9 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | kfreebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) + nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ + uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; @@ -144,7 +148,7 @@ case $os in -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis) + -apple | -axis | -knuth | -cray) os= basic_machine=$1 ;; @@ -169,6 +173,10 @@ case $os in -hiux*) os=-hiuxwe2 ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -185,6 +193,10 @@ case $os in # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` @@ -229,14 +241,16 @@ case $basic_machine in | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | am33_2.0 \ - | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \ + | bfin \ | c4x | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ - | m32r | m68000 | m68k | m88k | mcore \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -245,6 +259,7 @@ case $basic_machine in | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ @@ -253,20 +268,23 @@ case $basic_machine in | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ + | mt \ | msp430 \ + | nios | nios2 \ | ns16k | ns32k \ - | openrisc | or32 \ + | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ - | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ - | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ - | strongarm \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ | we32k \ - | x86 | xscale | xstormy16 | xtensa \ + | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; @@ -277,6 +295,9 @@ case $basic_machine in ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; + ms1) + basic_machine=mt-unknown + ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and @@ -296,10 +317,10 @@ case $basic_machine in | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ - | avr-* \ - | bs2000-* \ + | avr-* | avr32-* \ + | bfin-* | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | cydra-* \ + | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ @@ -307,9 +328,9 @@ case $basic_machine in | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ - | m32r-* \ + | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | mcore-* \ + | m88110-* | m88k-* | maxq-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ @@ -318,6 +339,7 @@ case $basic_machine in | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ @@ -325,24 +347,28 @@ case $basic_machine in | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ | msp430-* \ - | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ + | nios-* | nios2-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ - | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ - | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ - | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ - | xtensa-* \ + | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \ + | xstormy16-* | xtensa-* \ | ymp-* \ | z8k-*) ;; @@ -362,6 +388,9 @@ case $basic_machine in basic_machine=a29k-amd os=-udi ;; + abacus) + basic_machine=abacus-unknown + ;; adobe68k) basic_machine=m68010-adobe os=-scout @@ -379,6 +408,9 @@ case $basic_machine in amd64) basic_machine=x86_64-pc ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; amdahl) basic_machine=580-amdahl os=-sysv @@ -438,12 +470,27 @@ case $basic_machine in basic_machine=j90-cray os=-unicos ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16c) + basic_machine=cr16c-unknown + os=-elf + ;; crds | unos) basic_machine=m68k-crds ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; da30 | da30-*) basic_machine=m68k-da30 ;; @@ -466,6 +513,10 @@ case $basic_machine in basic_machine=m88k-motorola os=-sysv3 ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx @@ -644,10 +695,6 @@ case $basic_machine in mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; - mmix*) - basic_machine=mmix-knuth - os=-mmixware - ;; monitor) basic_machine=m68k-rom68k os=-coff @@ -660,6 +707,9 @@ case $basic_machine in basic_machine=i386-pc os=-msdos ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; mvs) basic_machine=i370-ibm os=-mvs @@ -728,10 +778,6 @@ case $basic_machine in np1) basic_machine=np1-gould ;; - nv1) - basic_machine=nv1-cray - os=-unicosmp - ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -739,9 +785,12 @@ case $basic_machine in basic_machine=hppa1.1-oki os=-proelf ;; - or32 | or32-*) + openrisc | openrisc-*) basic_machine=or32-unknown - os=-coff + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 ;; OSE68000 | ose68000) basic_machine=m68000-ericsson @@ -768,6 +817,12 @@ case $basic_machine in pc532 | pc532-*) basic_machine=ns32k-pc532 ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; @@ -824,6 +879,10 @@ case $basic_machine in basic_machine=i586-unknown os=-pw32 ;; + rdos) + basic_machine=i386-pc + os=-rdos + ;; rom68k) basic_machine=m68k-rom68k os=-coff @@ -963,6 +1022,10 @@ case $basic_machine in tower | tower-32) basic_machine=m68k-ncr ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; udi29k) basic_machine=a29k-amd os=-udi @@ -1006,6 +1069,10 @@ case $basic_machine in basic_machine=hppa1.1-winbond os=-proelf ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; xps | xps100) basic_machine=xps100-honeywell ;; @@ -1036,6 +1103,9 @@ case $basic_machine in romp) basic_machine=romp-ibm ;; + mmix) + basic_machine=mmix-knuth + ;; rs6000) basic_machine=rs6000-ibm ;; @@ -1052,13 +1122,10 @@ case $basic_machine in we32k) basic_machine=we32k-att ;; - sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) + sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; - sh64) - basic_machine=sh64-unknown - ;; - sparc | sparcv9 | sparcv9b) + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) basic_machine=sparc-sun ;; cydra) @@ -1131,19 +1198,23 @@ case $os in | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ - | -powermax* | -dnix* | -nx6 | -nx7 | -sei*) + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1161,7 +1232,7 @@ case $os in os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ - | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) @@ -1182,6 +1253,9 @@ case $os in -opened*) os=-openedition ;; + -os400*) + os=-os400 + ;; -wince*) os=-wince ;; @@ -1203,6 +1277,9 @@ case $os in -atheos*) os=-atheos ;; + -syllable*) + os=-syllable + ;; -386bsd) os=-bsd ;; @@ -1225,6 +1302,9 @@ case $os in -sinix*) os=-sysv4 ;; + -tpf*) + os=-tpf + ;; -triton*) os=-sysv3 ;; @@ -1261,6 +1341,9 @@ case $os in -kaos*) os=-kaos ;; + -zvmoe) + os=-zvmoe + ;; -none) ;; *) @@ -1283,6 +1366,9 @@ else # system, and we'll never get to this point. case $basic_machine in + spu-*) + os=-elf + ;; *-acorn) os=-riscix1.2 ;; @@ -1292,9 +1378,9 @@ case $basic_machine in arm*-semi) os=-aout ;; - c4x-* | tic4x-*) - os=-coff - ;; + c4x-* | tic4x-*) + os=-coff + ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 @@ -1338,9 +1424,15 @@ case $basic_machine in *-be) os=-beos ;; + *-haiku) + os=-haiku + ;; *-ibm) os=-aix ;; + *-knuth) + os=-mmixware + ;; *-wec) os=-proelf ;; @@ -1473,9 +1565,15 @@ case $basic_machine in -mvs* | -opened*) vendor=ibm ;; + -os400*) + vendor=ibm + ;; -ptx*) vendor=sequent ;; + -tpf*) + vendor=ibm + ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; @@ -1500,7 +1598,7 @@ case $basic_machine in esac echo $basic_machine$os -exit 0 +exit # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) diff --git a/src/config/lib.in b/src/config/lib.in index 40c245b083..5d362743da 100644 --- a/src/config/lib.in +++ b/src/config/lib.in @@ -89,6 +89,8 @@ hpux10.exports: $(SHLIB_EXPORT_FILE) Makefile else :; fi; \ done; echo "$$a" >> hpux10.tmp echo "+e errno" >> hpux10.tmp + echo "+e _GLOBAL__FD_lib$(LIBBASE)_$(LIBMAJOR)_$(LIBMINOR)" >> hpux10.tmp + echo "+e _GLOBAL__FI_lib$(LIBBASE)_$(LIBMAJOR)_$(LIBMINOR)" >> hpux10.tmp mv -f hpux10.tmp hpux10.exports lib$(LIBBASE)$(PFLIBEXT): $(PFOBJLISTS) diff --git a/src/config/post.in b/src/config/post.in index e960a455d4..a20edf9347 100644 --- a/src/config/post.in +++ b/src/config/post.in @@ -97,6 +97,8 @@ depend-update-makefile: .depend depend-recurse else :; fi DEPTARGETS = .depend .d .dtmp $(DEP_VERIFY) +DEPTARGETS_CLEAN = .depend .d .dtmp $(DEPTARGETS_@srcdir@_@CONFIG_RELTOPDIR@) +DEPTARGETS_@top_srcdir@_. = $(DEP_VERIFY) # # end dependency generation @@ -105,7 +107,7 @@ DEPTARGETS = .depend .d .dtmp $(DEP_VERIFY) clean:: clean-$(WHAT) clean-unix:: - $(RM) $(OBJS) $(DEPTARGETS) $(EXTRA_FILES) + $(RM) $(OBJS) $(DEPTARGETS_CLEAN) $(EXTRA_FILES) -$(RM) -r $(srcdir)/$(thisconfigdir)/autom4te.cache clean-windows:: diff --git a/src/config/pre.in b/src/config/pre.in index d05e06b676..cb7ac0cb1f 100644 --- a/src/config/pre.in +++ b/src/config/pre.in @@ -388,7 +388,7 @@ DES425_LIB = @DES425_LIB@ # HESIOD_LIBS is -lhesiod... HESIOD_LIBS = @HESIOD_LIBS@ -KRB5_BASE_LIBS = $(KRB5_LIB) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(GEN_LIB) $(LIBS) +KRB5_BASE_LIBS = $(KRB5_LIB) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(GEN_LIB) $(LIBS) $(DL_LIB) KRB4COMPAT_LIBS = $(KRB4_LIB) $(DES425_LIB) $(KRB5_BASE_LIBS) KDB5_LIBS = $(KDB5_LIB) GSS_LIBS = $(GSS_KRB5_LIB) diff --git a/src/config/shlib.conf b/src/config/shlib.conf index 1a1caad78b..fbd93393aa 100644 --- a/src/config/shlib.conf +++ b/src/config/shlib.conf @@ -287,7 +287,7 @@ mips-*-netbsd*) # libraries, without adding them to the dependency list. We need this because # the direct dependent libraries contain the pathname where the indirect # dependent libraries will be installed (but haven't been yet). - LDCOMBINE_TAIL='-dylib_file "$(KRB5_LIBDIR)/libkrb5support.1.0.dylib":$(TOPLIBD)/libkrb5support.1.0.dylib' + LDCOMBINE_TAIL='-dylib_file "$(KRB5_LIBDIR)/libkrb5support.1.1.dylib":$(TOPLIBD)/libkrb5support.1.1.dylib' CC_LINK_SHARED='$(CC) $(PROG_LIBPATH) -dynamic $(CFLAGS) $(LDFLAGS)' CC_LINK_STATIC='$(CC) $(PROG_LIBPATH) $(CFLAGS) $(LDFLAGS)' RUN_ENV='DYLD_LIBRARY_PATH=`echo $(PROG_LIBPATH) | sed -e "s/-L//g" -e "s/ /:/g"`; export DYLD_LIBRARY_PATH;' diff --git a/src/configure.in b/src/configure.in index b770fab998..cf93187ce8 100644 --- a/src/configure.in +++ b/src/configure.in @@ -878,6 +878,17 @@ dnl HOST_TYPE=$krb5_cv_host AC_SUBST(HOST_TYPE) dnl +dnl Sadly, we seem to have accidentally committed ourselves in 1.4 to +dnl an ABI that includes the existence of libkrb5support.0 even +dnl though random apps should never use anything from it. And on +dnl the Mac, to which that didn't apply, we can't use major version 0. +dnl +case $krb5_cv_host in +*-*-darwin* | *-*-rhapsody*) SUPPORTLIB_MAJOR=1 ;; +*) SUPPORTLIB_MAJOR=0 ;; +esac +AC_SUBST(SUPPORTLIB_MAJOR) +dnl dnl if test "$COM_ERR_VERSION" = k5 ; then dnl AC_CONFIG_SUBDIRS(util/et) diff --git a/src/include/Makefile.in b/src/include/Makefile.in index 313a017821..d1c6b4251d 100644 --- a/src/include/Makefile.in +++ b/src/include/Makefile.in @@ -26,6 +26,8 @@ BUILT_HEADERS = osconf.h all-unix:: autoconf.h $(BUILT_HEADERS) all-windows:: autoconf.h $(BUILT_HEADERS) +all-unix:: @MAINT@ verify-calling-conventions-krb5 + $(srcdir)/autoconf.h.in: @MAINT@ $(srcdir)/autoconf.stmp $(srcdir)/autoconf.stmp: $(srcdir)/$(thisconfigdir)/configure.in $(SRCTOP)/aclocal.m4 $(RM) -r $(srcdir)/$(thisconfigdir)/autom4te.cache @@ -80,6 +82,9 @@ krb5/krb5.h: $(srcdir)/krb5/krb5.hin krb5_err.h kdb5_err.h kv5m_err.h krb524_err cat $(srcdir)/krb5/krb5.hin krb5_err.h kdb5_err.h kv5m_err.h krb524_err.h \ asn1_err.h >> krb5/krb5.h +verify-calling-conventions-krb5: krb5/krb5.h + $(PERL) -w $(SRCTOP)/util/def-check.pl krb5/krb5.h $(SRCTOP)/lib/krb5_32.def + # # Build the error table include files: # asn1_err.h kdb5_err.h krb5_err.h kv5m_err.h krb524_err.h diff --git a/src/include/k5-int.h b/src/include/k5-int.h index 1bc3ed2d7c..a8b9e5d99a 100644 --- a/src/include/k5-int.h +++ b/src/include/k5-int.h @@ -1885,4 +1885,7 @@ krb5int_c_mandatory_cksumtype (krb5_context, krb5_enctype, krb5_cksumtype *); extern int krb5int_crypto_init (void); extern int krb5int_prng_init(void); +#define krb5_copy_error_state(CTX, OCTX) \ + krb5int_set_error(&(CTX)->errinfo, (OCTX)->errinfo.code, "%s", (OCTX)->errinfo.msg) + #endif /* _KRB5_INT_H */ diff --git a/src/include/krb5/krb5.hin b/src/include/krb5/krb5.hin index d786e6770c..603ed80283 100644 --- a/src/include/krb5/krb5.hin +++ b/src/include/krb5/krb5.hin @@ -1343,6 +1343,8 @@ krb5_error_code KRB5_CALLCONV krb5_init_secure_context (krb5_context *); void KRB5_CALLCONV krb5_free_context (krb5_context); +krb5_error_code KRB5_CALLCONV krb5_copy_context + (krb5_context, krb5_context *); #if KRB5_PRIVATE krb5_error_code krb5_set_default_in_tkt_ktypes @@ -2537,17 +2539,27 @@ krb5_prompt_type* KRB5_CALLCONV krb5_get_prompt_types (krb5_context context); /* Error reporting */ -void +void KRB5_CALLCONV_C krb5_set_error_message (krb5_context, krb5_error_code, const char *, ...); #ifdef va_start -void +void KRB5_CALLCONV krb5_vset_error_message (krb5_context, krb5_error_code, const char *, va_list); #endif -char * +/* + * The behavior of krb5_get_error_message is only defined the first + * time it is called after a failed call to a krb5 function using the + * same context, and only when the error code passed in is the same as + * that returned by the krb5 function. Future versions may return the + * same string for the second and following calls. + * + * The string returned by this function must be freed using + * krb5_free_error_message. + */ +char * KRB5_CALLCONV krb5_get_error_message (krb5_context, krb5_error_code); -void +void KRB5_CALLCONV krb5_free_error_message (krb5_context, char *); -void +void KRB5_CALLCONV krb5_clear_error_message (krb5_context); diff --git a/src/kadmin/cli/kadmin.c b/src/kadmin/cli/kadmin.c index 0b13420156..64b4c3f1c0 100644 --- a/src/kadmin/cli/kadmin.c +++ b/src/kadmin/cli/kadmin.c @@ -176,10 +176,14 @@ kadmin_parse_name(name, principal) static void extended_com_err_fn (const char *myprog, errcode_t code, const char *fmt, va_list args) { - const char *emsg; - emsg = krb5_get_error_message (context, code); - fprintf (stderr, "%s: %s ", myprog, emsg); - krb5_free_error_message (context, emsg); + if (code) { + const char *emsg; + emsg = krb5_get_error_message (context, code); + fprintf (stderr, "%s: %s ", myprog, emsg); + krb5_free_error_message (context, emsg); + } else { + fprintf (stderr, "%s: ", myprog); + } vfprintf (stderr, fmt, args); fprintf (stderr, "\n"); } @@ -404,7 +408,7 @@ char *kadmin_startup(argc, argv) if (realm - canon && *(realm - 1) != '\\') break; else - realm = strchr(realm, '@'); + realm = strchr(realm+1, '@'); } if (realm) *realm++ = '\0'; @@ -413,7 +417,7 @@ char *kadmin_startup(argc, argv) if (cp - canon && *(cp - 1) != '\\') break; else - cp = strchr(cp, '/'); + cp = strchr(cp+1, '/'); } if (cp != NULL) *cp = '\0'; @@ -725,6 +729,10 @@ void kadmin_cpw(argc, argv) } goto usage; } + if (*argv == NULL) { + com_err("change_password", 0, "missing principal name"); + goto usage; + } retval = kadmin_parse_name(*argv, &princ); if (retval) { com_err("change_password", retval, "while parsing principal name"); diff --git a/src/kadmin/dbutil/dump.c b/src/kadmin/dbutil/dump.c index 2ce811d0b5..f0d277c122 100644 --- a/src/kadmin/dbutil/dump.c +++ b/src/kadmin/dbutil/dump.c @@ -2121,23 +2121,12 @@ load_db(argc, argv) verbose = 1; else if (!strcmp(argv[aindex], updateoption)) update = 1; - else if (!strcmp(argv[aindex], hashoption)) - { - db5util_db_args_size++; - { - char **temp = realloc( db5util_db_args, sizeof(char*) * (db5util_db_args_size+1)); /* one for NULL */ - if( temp == NULL ) - { - com_err(progname, ENOMEM, "while parsing command arguments\n"); - exit(1); - } - - db5util_db_args = temp; + else if (!strcmp(argv[aindex], hashoption)) { + if (!add_db_arg("hash=true")) { + com_err(progname, ENOMEM, "while parsing command arguments\n"); + exit(1); } - db5util_db_args[db5util_db_args_size-1] = "hash=true"; - db5util_db_args[db5util_db_args_size] = NULL; - } - else + } else break; } if ((argc - aindex) != 1) { diff --git a/src/kadmin/dbutil/kdb5_create.c b/src/kadmin/dbutil/kdb5_create.c index b04595d65c..46bccce430 100644 --- a/src/kadmin/dbutil/kdb5_create.c +++ b/src/kadmin/dbutil/kdb5_create.c @@ -171,19 +171,11 @@ void kdb5_create(argc, argv) do_stash++; break; case 'h': - db5util_db_args_size++; - { - char **temp = realloc( db5util_db_args, sizeof(char*) * (db5util_db_args_size+1)); /* one for NULL */ - if( temp == NULL ) - { - com_err(progname, ENOMEM, "while parsing command arguments\n"); - exit(1); - } - - db5util_db_args = temp; + if (!add_db_arg("hash=true")) { + com_err(progname, ENOMEM, "while parsing command arguments\n"); + exit(1); } - db5util_db_args[db5util_db_args_size-1] = "hash=true"; - db5util_db_args[db5util_db_args_size] = NULL; + break; case '?': default: usage(); diff --git a/src/kadmin/dbutil/kdb5_util.c b/src/kadmin/dbutil/kdb5_util.c index 0e308e54ec..00c87a2256 100644 --- a/src/kadmin/dbutil/kdb5_util.c +++ b/src/kadmin/dbutil/kdb5_util.c @@ -149,13 +149,31 @@ static void extended_com_err_fn (const char *myprog, errcode_t code, const char *fmt, va_list args) { const char *emsg; - emsg = krb5_get_error_message (util_context, code); - fprintf (stderr, "%s: %s ", myprog, emsg); - krb5_free_error_message (util_context, emsg); + if (code) { + emsg = krb5_get_error_message (util_context, code); + fprintf (stderr, "%s: %s ", myprog, emsg); + krb5_free_error_message (util_context, emsg); + } else { + fprintf (stderr, "%s: ", myprog); + } vfprintf (stderr, fmt, args); fprintf (stderr, "\n"); } +int add_db_arg(char *arg) +{ + char **temp; + db5util_db_args_size++; + temp = realloc(db5util_db_args, + sizeof(char *) * (db5util_db_args_size + 1)); + if (temp == NULL) + return 0; + db5util_db_args = temp; + db5util_db_args[db5util_db_args_size-1] = arg; + db5util_db_args[db5util_db_args_size] = NULL; + return 1; +} + int main(argc, argv) int argc; char *argv[]; @@ -205,35 +223,18 @@ int main(argc, argv) strcpy( db_name_tmp, "dbname="); strcat( db_name_tmp, global_params.dbname ); - db5util_db_args_size++; - { - char **temp = realloc( db5util_db_args, sizeof(char*) * (db5util_db_args_size+1)); /* one for NULL */ - if( temp == NULL ) - { - com_err(progname, ENOMEM, "while parsing command arguments\n"); - exit(1); - } - - db5util_db_args = temp; + if (!add_db_arg(db_name_tmp)) { + com_err(progname, ENOMEM, "while parsing command arguments\n"); + exit(1); } - db5util_db_args[db5util_db_args_size-1] = db_name_tmp; - db5util_db_args[db5util_db_args_size] = NULL; } else if (strcmp(*argv, "-x") == 0 && ARG_VAL) { db5util_db_args_size++; - { - char **temp = realloc( db5util_db_args, sizeof(char*) * (db5util_db_args_size+1)); /* one for NULL */ - if( temp == NULL ) - { - fprintf(stderr,"%s: Cannot initialize. Not enough memory\n", - argv[0]); - exit(1); - } - - db5util_db_args = temp; + if (!add_db_arg(koptarg)) { + fprintf(stderr,"%s: Cannot initialize. Not enough memory\n", + argv[0]); + exit(1); } - db5util_db_args[db5util_db_args_size-1] = koptarg; - db5util_db_args[db5util_db_args_size] = NULL; } else if (strcmp(*argv, "-r") == 0 && ARG_VAL) { global_params.realm = koptarg; diff --git a/src/kadmin/dbutil/kdb5_util.h b/src/kadmin/dbutil/kdb5_util.h index bb6b0ac64a..90b7b43ef3 100644 --- a/src/kadmin/dbutil/kdb5_util.h +++ b/src/kadmin/dbutil/kdb5_util.h @@ -42,6 +42,7 @@ extern int valid_master_key; extern krb5_db_entry master_db; extern char **db5util_db_args; extern int db5util_db_args_size; +extern int add_db_arg(char *arg); extern void usage(void); diff --git a/src/kdc/Makefile.in b/src/kdc/Makefile.in index 5ea5ea3922..0a932518ae 100644 --- a/src/kdc/Makefile.in +++ b/src/kdc/Makefile.in @@ -193,9 +193,9 @@ $(OUTPRE)kerberos_v4.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(SRCTOP)/include/k5-err.h $(SRCTOP)/include/k5-int.h \ $(SRCTOP)/include/k5-platform.h $(SRCTOP)/include/k5-plugin.h \ $(SRCTOP)/include/k5-thread.h $(SRCTOP)/include/kdb.h \ - $(SRCTOP)/include/kerberosIV/des.h $(SRCTOP)/include/kerberosIV/kdc.h \ - $(SRCTOP)/include/kerberosIV/klog.h $(SRCTOP)/include/kerberosIV/krb.h \ - $(SRCTOP)/include/kerberosIV/krb_db.h $(SRCTOP)/include/kerberosIV/prot.h \ - $(SRCTOP)/include/krb5.h $(SRCTOP)/include/krb5/locate_plugin.h \ - $(SRCTOP)/include/port-sockets.h $(SRCTOP)/include/socket-utils.h \ - $(SRCTOP)/include/syslog.h extern.h kdc_util.h kerberos_v4.c + $(SRCTOP)/include/kerberosIV/des.h $(SRCTOP)/include/kerberosIV/klog.h \ + $(SRCTOP)/include/kerberosIV/krb.h $(SRCTOP)/include/kerberosIV/krb_db.h \ + $(SRCTOP)/include/kerberosIV/prot.h $(SRCTOP)/include/krb5.h \ + $(SRCTOP)/include/krb5/locate_plugin.h $(SRCTOP)/include/port-sockets.h \ + $(SRCTOP)/include/socket-utils.h $(SRCTOP)/include/syslog.h \ + extern.h kdc_util.h kerberos_v4.c diff --git a/src/kdc/kerberos_v4.c b/src/kdc/kerberos_v4.c index a11e6225ac..9f93e451e2 100644 --- a/src/kdc/kerberos_v4.c +++ b/src/kdc/kerberos_v4.c @@ -62,7 +62,6 @@ #include #include #include -#include #ifdef NEED_SWAB_PROTO extern void swab(const void *, void *, size_t ); @@ -70,7 +69,7 @@ extern void swab(const void *, void *, size_t ); static int compat_decrypt_key (krb5_key_data *, C_Block, krb5_keyblock *, int); -static int kerb_get_principal (char *, char *, Principal *, int, +static int kerb_get_principal (char *, char *, Principal *, int *, krb5_keyblock *, krb5_kvno, int, krb5_deltat *); static int check_princ (char *, char *, int, Principal *, @@ -401,7 +400,6 @@ compat_decrypt_key (krb5_key_data *in5, unsigned char *out4, static int kerb_get_principal(char *name, char *inst, /* could have wild cards */ Principal *principal, - int maxn, /* max # name structs to return */ int *more, /* more tuples than room for */ krb5_keyblock *k5key, krb5_kvno kvno, int issrv, /* true if retrieving a service key */ @@ -424,10 +422,6 @@ kerb_get_principal(char *name, char *inst, /* could have wild cards */ krb5_error_code retval; *more = 0; - if ( maxn > 1) { - lt = klog(L_DEATH_REQ, "KDC V4 is requesting too many principals"); - return( 0); - } /* begin setting up the principal structure * with the first info we have: */ @@ -453,7 +447,7 @@ kerb_get_principal(char *name, char *inst, /* could have wild cards */ krb5_free_principal(kdc_context, search); if (nprinc < 1) { - *more = (int)more5 || (nprinc > maxn); + *more = (int)more5 || (nprinc > 1); return(nprinc); } @@ -576,7 +570,7 @@ kerb_get_principal(char *name, char *inst, /* could have wild cards */ * this routine clears the keyblock's contents for us. */ krb5_db_free_principal(kdc_context, &entries, nprinc); - *more = (int) more5 || (nprinc > maxn); + *more = (int) more5 || (nprinc > 1); return( nprinc); } @@ -804,7 +798,7 @@ kerberos_v4(struct sockaddr_in *client, KTEXT pkt) req_realm_ptr, req_time_ws, 0, a_name_data.exp_date, a_name_data.key_version, ciph); krb4_sendto(f, (char *) rpkt->dat, rpkt->length, 0, - (struct sockaddr *) client, S_AD_SZ); + (struct sockaddr *) client, sizeof (struct sockaddr_in)); memset(&a_name_data, 0, sizeof(a_name_data)); memset(&s_name_data, 0, sizeof(s_name_data)); break; @@ -982,7 +976,7 @@ kerberos_v4(struct sockaddr_in *client, KTEXT pkt) ad->prealm, time_ws, 0, 0, 0, ciph); krb4_sendto(f, (char *) rpkt->dat, rpkt->length, 0, - (struct sockaddr *) client, S_AD_SZ); + (struct sockaddr *) client, sizeof (struct sockaddr_in)); memset(&s_name_data, 0, sizeof(s_name_data)); break; } @@ -1028,7 +1022,7 @@ kerb_err_reply(struct sockaddr_in *client, KTEXT pkt, long int err, char *string cr_err_reply(e_pkt, req_name_ptr, req_inst_ptr, req_realm_ptr, req_time_ws, err, e_msg); krb4_sendto(f, (char *) e_pkt->dat, e_pkt->length, 0, - (struct sockaddr *) client, S_AD_SZ); + (struct sockaddr *) client, sizeof (struct sockaddr_in)); } @@ -1040,7 +1034,7 @@ check_princ(char *p_name, char *instance, int lifetime, Principal *p, static int more; /* long trans; */ - n = kerb_get_principal(p_name, instance, p, 1, &more, k5key, 0, + n = kerb_get_principal(p_name, instance, p, &more, k5key, 0, issrv, k5life); klog(L_ALL_REQ, "Principal: \"%s\", Instance: \"%s\" Lifetime = %d n = %d", @@ -1161,7 +1155,7 @@ set_tgtkey(char *r, krb5_kvno kvno, krb5_boolean use_3des) /* log("Getting key for %s", r); */ - n = kerb_get_principal("krbtgt", r, p, 1, &more, &k5key, kvno, 1, NULL); + n = kerb_get_principal("krbtgt", r, p, &more, &k5key, kvno, 1, NULL); if (n == 0) return (KFAILURE); diff --git a/src/kdc/network.c b/src/kdc/network.c index af5e7d0362..42c487a2c8 100644 --- a/src/kdc/network.c +++ b/src/kdc/network.c @@ -891,6 +891,36 @@ kill_tcp_connection(struct connection *conn) tcp_data_counter--; } +static krb5_error_code +make_toolong_error (krb5_data **out) +{ + krb5_error errpkt; + krb5_error_code retval; + krb5_data *scratch; + + retval = krb5_us_timeofday(kdc_context, &errpkt.stime, &errpkt.susec); + if (retval) + return retval; + errpkt.error = KRB_ERR_FIELD_TOOLONG; + errpkt.server = tgs_server; + errpkt.client = NULL; + errpkt.text.length = 0; + errpkt.text.data = 0; + errpkt.e_data.length = 0; + errpkt.e_data.data = 0; + scratch = malloc(sizeof(*scratch)); + if (scratch == NULL) + return ENOMEM; + retval = krb5_mk_error(kdc_context, &errpkt, scratch); + if (retval) { + free(scratch); + return retval; + } + + *out = scratch; + return 0; +} + static void process_tcp_connection(struct connection *conn, const char *prog, int selflags) { @@ -921,7 +951,10 @@ process_tcp_connection(struct connection *conn, const char *prog, int selflags) } if (conn->u.tcp.sgnum == 0) { /* finished sending */ - /* should go back to reading */ + /* We should go back to reading, though if we sent a + FIELD_TOOLONG error in reply to a length with the high + bit set, RFC 4120 says we have to close the TCP + stream. */ goto kill_tcp_connection; } } else if (selflags & SSF_READ) { @@ -953,12 +986,20 @@ process_tcp_connection(struct connection *conn, const char *prog, int selflags) | (p[2] << 8) | p[3]); if (conn->u.tcp.msglen > conn->u.tcp.bufsiz - 4) { + krb5_error_code err; /* message too big */ krb5_klog_syslog(LOG_ERR, "TCP client %s wants %lu bytes, cap is %lu", conn->u.tcp.addrbuf, (unsigned long) conn->u.tcp.msglen, (unsigned long) conn->u.tcp.bufsiz - 4); /* XXX Should return an error. */ - goto kill_tcp_connection; + err = make_toolong_error (&conn->u.tcp.response); + if (err) { + krb5_klog_syslog(LOG_ERR, + "error constructing KRB_ERR_FIELD_TOOLONG error! %s", + error_message(err)); + goto kill_tcp_connection; + } + goto have_response; } } } else { @@ -987,6 +1028,7 @@ process_tcp_connection(struct connection *conn, const char *prog, int selflags) com_err(prog, err, "while dispatching (tcp)"); goto kill_tcp_connection; } + have_response: conn->u.tcp.lenbuf[0] = 0xff & (conn->u.tcp.response->length >> 24); conn->u.tcp.lenbuf[1] = 0xff & (conn->u.tcp.response->length >> 16); conn->u.tcp.lenbuf[2] = 0xff & (conn->u.tcp.response->length >> 8); diff --git a/src/krb5-config.in b/src/krb5-config.in index cf2be4947d..341450cd28 100755 --- a/src/krb5-config.in +++ b/src/krb5-config.in @@ -38,6 +38,7 @@ KDB5_DB_LIB=@KDB5_DB_LIB@ LDFLAGS='@LDFLAGS@' RPATH_FLAG='@RPATH_FLAG@' PTHREAD_CFLAGS='@PTHREAD_CFLAGS@' +DL_LIB='@DL_LIB@' LIBS='@LIBS@' GEN_LIB=@GEN_LIB@ @@ -216,7 +217,7 @@ if test -n "$do_libs"; then fi if test $library = 'krb5'; then - lib_flags="$lib_flags -lkrb5 -lk5crypto -lcom_err -lkrb5support $GEN_LIB $LIBS" + lib_flags="$lib_flags -lkrb5 -lk5crypto -lcom_err $GEN_LIB $LIBS $DL_LIB" fi echo $lib_flags diff --git a/src/lib/apputils/Makefile.in b/src/lib/apputils/Makefile.in index 9393f56bf2..554abad8b2 100644 --- a/src/lib/apputils/Makefile.in +++ b/src/lib/apputils/Makefile.in @@ -32,8 +32,8 @@ LIBOBJS=$(OUTPRE)daemon.$(OBJEXT) SRCS= $(srcdir)/daemon.c \ $(srcdir)/dummy.c -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/ccapi/NTMakefile b/src/lib/ccapi/NTMakefile new file mode 100644 index 0000000000..57c42e337e --- /dev/null +++ b/src/lib/ccapi/NTMakefile @@ -0,0 +1,25 @@ +CD = cd + +all: + $(CD) common + $(MAKE) -f NTMakefile all + $(CD) ../client + $(MAKE) -f NTMakefile all + $(CD) ../server + $(MAKE) -f NTMakefile all + $(CD) ../windows + $(MAKE) -f NTMakefile all + $(CD) .. + +clean: + $(CD) common + $(MAKE) -f NTMakefile clean + $(CD) ../client + $(MAKE) -f NTMakefile clean + $(CD) ../server + $(MAKE) -f NTMakefile clean + $(CD) ../windows + $(MAKE) -f NTMakefile clean + $(CD) .. + + diff --git a/src/lib/ccapi/client/NTMakefile b/src/lib/ccapi/client/NTMakefile index 09ef9df38b..2ce87c3507 100644 --- a/src/lib/ccapi/client/NTMakefile +++ b/src/lib/ccapi/client/NTMakefile @@ -1,22 +1,18 @@ !INCLUDE -CFLAGS = -I../include +CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsmt) -CCAPI_OBJS = cacheapi.obj context.obj ccache.obj credentials.obj ccache_iterator.obj \ - credentials_iterator.obj ccstring.obj marshall.obj msg.obj +CC_CLIENT_OBJS = cacheapi.obj context.obj ccache.obj credentials.obj ccache_iterator.obj \ + credentials_iterator.obj ccstring.obj ccapiv2.obj -CCAPI_LIB = ccapi.lib - -$(CCAPI_LIB): $(CCAPI_OBJS) - $(implib) /NOLOGO /OUT:$@ $** - -CCAPI_DLLFILE = krbcc32.dll +CC_CLIENT_LIB = cc_client.lib +CC_COMMON_LIB = ..\common\cc_common.lib +$(CC_CLIENT_LIB): $(CC_CLIENT_OBJS) + $(implib) /NOLOGO /OUT:$@ $** -$(CCAPI_DLLFILE): $(CCAPI_LIB) - $(DLLGUILINK) -def:windows\krbcc32.def - $(DLLPREP) +all: $(CC_CLIENT_LIB) clean: del *.obj *.lib diff --git a/src/lib/ccapi/client/cacheapi.c b/src/lib/ccapi/client/cacheapi.c index 2c874bec0f..89c5e63d1b 100644 --- a/src/lib/ccapi/client/cacheapi.c +++ b/src/lib/ccapi/client/cacheapi.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -43,33 +43,43 @@ #include #include +#include #include #include "ccache.h" #include "ccache_iterator.h" #include "context.h" +#include "cc_rpc.h" #include "msg.h" #include "msg_headers.h" -cc_int32 +/*! \fn cc_initialize + * \brief A function that initializes a ccapi context for the caller. + * \param[out] outContext a cc_context_t pointer to which is assigned the newly created context upon success. + * \param[in] inVersion a cc_int32 that specifies the + */ + +CCACHE_API cc_int32 cc_initialize ( cc_context_t* outContext, cc_int32 inVersion, cc_int32* outSupportedVersion, char const** outVendor) { static char vendor[128] = ""; - cc_msg_t *request; + cc_msg_t *request = NULL; ccmsg_init_t *request_header; - cc_msg_t *response; + cc_msg_t *response = NULL; + cc_uint32 type; ccmsg_init_resp_t *response_header; cc_int32 code; if ((inVersion != ccapi_version_2) && (inVersion != ccapi_version_3) && (inVersion != ccapi_version_4) && - (inVersion != ccapi_version_5)) { + (inVersion != ccapi_version_5) && + (inVersion != ccapi_version_6)) { if (outSupportedVersion != NULL) { - *outSupportedVersion = ccapi_version_5; + *outSupportedVersion = ccapi_version_6; } return ccErrBadAPIVersion; } @@ -78,29 +88,43 @@ cc_initialize ( cc_context_t* outContext, if (request_header == NULL) return ccErrNoMem; - request_header->in_version = inVersion; + /* If the version number is 2, the caller will be passing + * the structure into the v2 compatibility functions which + * in turn will call the v6 functions. Set the version to + * ccapi_version_max since that is what the compatibility + * functions will be expecting. + */ + if (inVersion == ccapi_version_2) + inVersion = ccapi_version_max; + + /* Construct the request */ + request_header->in_version = htonl(inVersion); code = cci_msg_new(ccmsg_INIT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_init_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_init_resp_t *)response->header; - *outSupportedVersion = response_header->out_version; - code = cc_context_int_new(outContext, response_header->out_ctx, response_header->out_version); + *outSupportedVersion = ntohl(response_header->out_version); + code = cc_int_context_new(outContext, ntohll(response_header->out_ctx), ntohl(response_header->out_version)); if (!vendor[0]) { char * string; - code = cci_msg_retrieve_blob(response, response_header->vendor_offset, response_header->vendor_length, &string); + code = cci_msg_retrieve_blob(response, ntohl(response_header->vendor_offset), ntohl(response_header->vendor_length), &string); strncpy(vendor, string, sizeof(vendor)-1); vendor[sizeof(vendor)-1] = '\0'; free(string); @@ -111,8 +135,15 @@ cc_initialize ( cc_context_t* outContext, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } diff --git a/src/lib/ccapi/client/ccache.c b/src/lib/ccapi/client/ccache.c index 5de3880e4f..07e9b8e879 100644 --- a/src/lib/ccapi/client/ccache.c +++ b/src/lib/ccapi/client/ccache.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -46,11 +46,21 @@ #include #include +#include #include #include "credentials.h" +#include "credentials_iterator.h" #include "ccache.h" +#include "cc_rpc.h" #include "msg.h" #include "msg_headers.h" +#include "ccstring.h" + +/* + * cc_int_ccache_new + * + * Input parameters in host order. + */ cc_int32 cc_int_ccache_new( cc_ccache_t * pccache, cc_handle hctx, cc_handle hccache ) @@ -97,11 +107,12 @@ cc_int_ccache_new( cc_ccache_t * pccache, cc_handle hctx, cc_handle hccache ) cc_int32 cc_int_ccache_release( cc_ccache_t ccache ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_release_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_release_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -114,30 +125,41 @@ cc_int_ccache_release( cc_ccache_t ccache ) request_header = (ccmsg_ccache_release_t*)malloc(sizeof(ccmsg_ccache_release_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_RELEASE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_release_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); - free(int_ccache->functions); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); + if (int_ccache->functions) + free(int_ccache->functions); free(int_ccache); return code; } @@ -146,11 +168,12 @@ cc_int_ccache_release( cc_ccache_t ccache ) cc_int32 cc_int_ccache_destroy( cc_ccache_t ccache ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_destroy_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_destroy_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -163,29 +186,39 @@ cc_int_ccache_destroy( cc_ccache_t ccache ) request_header = (ccmsg_ccache_destroy_t*)malloc(sizeof(ccmsg_ccache_destroy_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_DESTROY, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_destroy_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); free(ccache); return code; } @@ -194,11 +227,12 @@ cc_int_ccache_destroy( cc_ccache_t ccache ) cc_int32 cc_int_ccache_set_default( cc_ccache_t ccache ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_set_default_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_set_default_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -211,29 +245,39 @@ cc_int_ccache_set_default( cc_ccache_t ccache ) request_header = (ccmsg_ccache_set_default_t*)malloc(sizeof(ccmsg_ccache_set_default_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_SET_DEFAULT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_set_default_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -241,11 +285,12 @@ cc_int32 cc_int_ccache_get_credentials_version( cc_ccache_t ccache, cc_uint32* credentials_version) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_get_creds_version_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_get_creds_version_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -258,43 +303,53 @@ cc_int_ccache_get_credentials_version( cc_ccache_t ccache, request_header = (ccmsg_ccache_get_creds_version_t*)malloc(sizeof(ccmsg_ccache_get_creds_version_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_GET_CREDS_VERSION, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_get_creds_version_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { ccmsg_ccache_get_creds_version_resp_t * response_header = (ccmsg_ccache_get_creds_version_resp_t*)response->header; - *credentials_version = response_header->version; + *credentials_version = ntohl(response_header->version); code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } cc_int32 -cc_int_ccache_get_name( cc_ccache_t ccache, - cc_string_t* name ) +cc_int_ccache_get_name( cc_ccache_t ccache, cc_string_t* name ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_get_name_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_get_name_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -307,36 +362,46 @@ cc_int_ccache_get_name( cc_ccache_t ccache, request_header = (ccmsg_ccache_get_name_t*)malloc(sizeof(ccmsg_ccache_get_name_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_GET_NAME, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_get_name_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { char * string; ccmsg_ccache_get_name_resp_t * response_header = (ccmsg_ccache_get_name_resp_t*)response->header; code = cci_msg_retrieve_blob(response, response_header->name_offset, response_header->name_len, &string); if (code == ccNoError) { - code = cc_string_new(&name, string); + code = cci_string_new(name, string); free(string); } } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -345,11 +410,12 @@ cc_int_ccache_get_principal( cc_ccache_t ccache, cc_uint32 credentials_version, cc_string_t* principal ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_get_principal_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_get_principal_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -362,37 +428,47 @@ cc_int_ccache_get_principal( cc_ccache_t ccache, request_header = (ccmsg_ccache_get_principal_t*)malloc(sizeof(ccmsg_ccache_get_principal_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; - request_header->version = credentials_version; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); + request_header->version = htonl(credentials_version); code = cci_msg_new(ccmsg_CCACHE_GET_PRINCIPAL, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_get_principal_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { char * string; ccmsg_ccache_get_principal_resp_t * response_header = (ccmsg_ccache_get_principal_resp_t*)response->header; code = cci_msg_retrieve_blob(response, response_header->principal_offset, response_header->principal_len, &string); if (code == ccNoError) { - code = cc_string_new(&principal, string); + code = cci_string_new(principal, string); free(string); } } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -401,12 +477,13 @@ cc_int_ccache_set_principal( cc_ccache_t ccache, cc_uint32 credentials_version, const char* principal ) { - cc_uint32 blob_pos; - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_set_principal_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_uint32 blob_pos; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_set_principal_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -419,40 +496,47 @@ cc_int_ccache_set_principal( cc_ccache_t ccache, request_header = (ccmsg_ccache_set_principal_t*)malloc(sizeof(ccmsg_ccache_set_principal_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; - request_header->version = credentials_version; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); + request_header->version = htonl(credentials_version); code = cci_msg_new(ccmsg_CCACHE_GET_PRINCIPAL, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_data_blob(request, (void*)principal, strlen(principal) + 1, &blob_pos); - if (code != ccNoError) { - cci_msg_destroy(request); - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; - request_header->principal_offset = blob_pos; - request_header->principal_len = strlen(principal) + 1; + request_header->principal_offset = htonl(blob_pos); + request_header->principal_len = htonl(strlen(principal) + 1); code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_set_principal_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -460,11 +544,12 @@ cc_int32 cc_int_ccache_new_credentials_iterator( cc_ccache_t ccache, cc_credentials_iterator_t* iterator ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_creds_iterator_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_creds_iterator_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -477,30 +562,41 @@ cc_int_ccache_new_credentials_iterator( cc_ccache_t ccache, request_header = (ccmsg_ccache_creds_iterator_t*)malloc(sizeof(ccmsg_ccache_creds_iterator_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); - code = cci_msg_new(ccmsg_CCACHE_CREDS_ITERATOR, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + code = cci_msg_new(ccmsg_CCACHE_NEW_CREDS_ITERATOR, &request); + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_creds_iterator_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { ccmsg_ccache_creds_iterator_resp_t * response_header = (ccmsg_ccache_creds_iterator_resp_t*)response->header; - code = cc_int_credentials_iterator_new(iterator, response_header->iterator); + code = cc_int_credentials_iterator_new(iterator, int_ccache->ctx, int_ccache->handle, + ntohll(response_header->iterator)); } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -508,14 +604,15 @@ cc_int32 cc_int_ccache_store_credentials( cc_ccache_t ccache, const cc_credentials_union* credentials ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_store_creds_t *request_header; - cc_msg_t *response; - char *flat_cred = 0; - cc_uint32 flat_cred_len = 0; - cc_uint32 blob_pos; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_store_creds_t *request_header = NULL; + cc_msg_t *response = NULL; + char *flat_cred = 0; + cc_uint32 flat_cred_len = 0; + cc_uint32 blob_pos; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL || credentials == NULL ) return ccErrBadParam; @@ -528,14 +625,12 @@ cc_int_ccache_store_credentials( cc_ccache_t ccache, request_header = (ccmsg_ccache_store_creds_t*)malloc(sizeof(ccmsg_ccache_store_creds_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_STORE_CREDS, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; switch ( credentials->version ) { case cc_credentials_v4: @@ -545,42 +640,47 @@ cc_int_ccache_store_credentials( cc_ccache_t ccache, code = cci_creds_v5_marshall(credentials->credentials.credentials_v5, &flat_cred, &flat_cred_len); break; default: - cci_msg_destroy(request); - free(request_header); - return ccErrBadCredentialsVersion; - } - if (code != ccNoError) { - cci_msg_destroy(request); - free(request_header); - return code; + code = ccErrBadCredentialsVersion; } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_data_blob(request, (void*)flat_cred, flat_cred_len, &blob_pos); - if (code != ccNoError) { - cci_msg_destroy(request); - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; - request_header->creds_version = credentials->version; - request_header->creds_offset = blob_pos; - request_header->creds_len = flat_cred_len; + request_header->creds_version = htonl(credentials->version); + request_header->creds_offset = htonl(blob_pos); + request_header->creds_len = htonl(flat_cred_len); code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_store_creds_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - free(flat_cred); - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (flat_cred) + free(flat_cred); + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -588,12 +688,13 @@ cc_int32 cc_int_ccache_remove_credentials( cc_ccache_t ccache, cc_credentials_t credentials ) { - cc_int_ccache_t int_ccache; - cc_int_credentials_t int_creds; - cc_msg_t *request; - ccmsg_ccache_rem_creds_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_int_credentials_t int_creds; + cc_msg_t *request = NULL; + ccmsg_ccache_rem_creds_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL || credentials == NULL ) return ccErrBadParam; @@ -611,30 +712,40 @@ cc_int_ccache_remove_credentials( cc_ccache_t ccache, if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; - request_header->creds = int_creds->handle; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); + request_header->creds = htonll(int_creds->handle); code = cci_msg_new(ccmsg_CCACHE_REM_CREDS, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_rem_creds_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -643,12 +754,13 @@ cc_int32 cc_int_ccache_move( cc_ccache_t source, cc_ccache_t destination ) { - cc_int_ccache_t int_ccache_source; - cc_int_ccache_t int_ccache_dest; - cc_msg_t *request; - ccmsg_ccache_move_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache_source; + cc_int_ccache_t int_ccache_dest; + cc_msg_t *request = NULL; + ccmsg_ccache_move_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( source == NULL || destination == NULL ) return ccErrBadParam; @@ -668,29 +780,39 @@ cc_int_ccache_move( cc_ccache_t source, return ccErrNoMem; code = cci_msg_new(ccmsg_CCACHE_MOVE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; - request_header->ctx = int_ccache_source->ctx; - request_header->ccache_source = int_ccache_source->handle; - request_header->ccache_dest = int_ccache_dest->handle; + request_header->ctx = htonll(int_ccache_source->ctx); + request_header->ccache_source = htonll(int_ccache_source->handle); + request_header->ccache_dest = htonll(int_ccache_dest->handle); code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_move_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -698,14 +820,16 @@ cc_int_ccache_lock( cc_ccache_t ccache, cc_uint32 lock_type, cc_uint32 block ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_lock_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_lock_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL || - (lock_type != cc_lock_read && lock_type != cc_lock_write) || + (lock_type != cc_lock_read && lock_type != cc_lock_write && + lock_type != cc_lock_upgrade && lock_type != cc_lock_downgrade) || (block != cc_lock_block && block != cc_lock_noblock) ) return ccErrBadParam; @@ -719,22 +843,26 @@ cc_int_ccache_lock( cc_ccache_t ccache, return ccErrNoMem; code = cci_msg_new(ccmsg_CCACHE_LOCK, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; - request_header->lock_type; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); + request_header->lock_type = htonl(lock_type); code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_lock_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; + code = ntohl(nack_header->err_code); // TODO: if (block == cc_lock_block) ..... } else if (response->type == ccmsg_ACK) { @@ -742,19 +870,26 @@ cc_int_ccache_lock( cc_ccache_t ccache, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } cc_int32 cc_int_ccache_unlock( cc_ccache_t ccache ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_unlock_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_unlock_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -769,41 +904,53 @@ cc_int_ccache_unlock( cc_ccache_t ccache ) return ccErrNoMem; code = cci_msg_new(ccmsg_CCACHE_UNLOCK, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_unlock_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = htonl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = htonl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } cc_int32 cc_int_ccache_get_last_default_time( cc_ccache_t ccache, - cc_time_t* time_offset ) + cc_time* time_offset ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_get_last_default_time_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_get_last_default_time_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_time64 t64; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -816,43 +963,56 @@ cc_int_ccache_get_last_default_time( cc_ccache_t ccache, request_header = (ccmsg_ccache_get_last_default_time_t*)malloc(sizeof(ccmsg_ccache_get_last_default_time_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_GET_LAST_DEFAULT_TIME, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_get_last_default_time_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { ccmsg_ccache_get_last_default_time_resp_t * response_header = (ccmsg_ccache_get_last_default_time_resp_t*)response->header; - *time_offset = response_header->last_default_time; - code = ccNoError; + t64 = ntohll(response_header->last_default_time); + /* TODO: validate that we do not overflow the max value of time_offset */ + *time_offset = t64; + code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } cc_int32 -cc_int_ccache_get_change_time( cc_ccache_t ccache, - cc_time_t* time ) +cc_int_ccache_get_change_time( cc_ccache_t ccache, cc_time* time ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_get_change_time_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_get_change_time_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_time64 t64; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -865,31 +1025,43 @@ cc_int_ccache_get_change_time( cc_ccache_t ccache, request_header = (ccmsg_ccache_get_change_time_t*)malloc(sizeof(ccmsg_ccache_get_change_time_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); code = cci_msg_new(ccmsg_CCACHE_GET_CHANGE_TIME, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_get_change_time_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { ccmsg_ccache_get_change_time_resp_t * response_header = (ccmsg_ccache_get_change_time_resp_t*)response->header; - *time = response_header->time; + t64 = htonll(response_header->time); + /* TODO: validate that we do not overflow 'time' */ + *time = t64; code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -898,12 +1070,13 @@ cc_int_ccache_compare( cc_ccache_t ccache, cc_ccache_t compare_to, cc_uint32* equal ) { - cc_int_ccache_t int_ccache; - cc_int_ccache_t int_compare_to; - cc_msg_t *request; - ccmsg_ccache_compare_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_int_ccache_t int_compare_to; + cc_msg_t *request = NULL; + ccmsg_ccache_compare_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -918,45 +1091,56 @@ cc_int_ccache_compare( cc_ccache_t ccache, request_header = (ccmsg_ccache_compare_t*)malloc(sizeof(ccmsg_ccache_compare_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache1 = int_ccache->handle; - request_header->ccache2 = int_compare_to->handle; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache1 = htonll(int_ccache->handle); + request_header->ccache2 = htonll(int_compare_to->handle); code = cci_msg_new(ccmsg_CCACHE_COMPARE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_compare_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { ccmsg_ccache_compare_resp_t * response_header = (ccmsg_ccache_compare_resp_t*)response->header; - *equal = response_header->is_equal; + *equal = ntohl(response_header->is_equal); code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } cc_int32 cc_int_ccache_get_kdc_time_offset( cc_ccache_t ccache, cc_int32 credentials_version, - cc_time_t* time_offset ) + cc_time* time_offset ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_get_kdc_time_offset_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_get_kdc_time_offset_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -969,45 +1153,57 @@ cc_int_ccache_get_kdc_time_offset( cc_ccache_t ccache, request_header = (ccmsg_ccache_get_kdc_time_offset_t*)malloc(sizeof(ccmsg_ccache_get_kdc_time_offset_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; - request_header->creds_version = credentials_version; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); + request_header->creds_version = htonl(credentials_version); code = cci_msg_new(ccmsg_CCACHE_GET_KDC_TIME_OFFSET, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_get_kdc_time_offset_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; + code = ntohl(nack_header->err_code); } else if (response->type == ccmsg_ACK) { ccmsg_ccache_get_kdc_time_offset_resp_t * response_header = (ccmsg_ccache_get_kdc_time_offset_resp_t*)response->header; - *time_offset = response_header->offset; + *time_offset = (cc_time64)ntohll(response_header->offset); code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } cc_int32 cc_int_ccache_set_kdc_time_offset( cc_ccache_t ccache, cc_int32 credentials_version, - cc_time_t time_offset ) + cc_time time_offset ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_set_kdc_time_offset_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_set_kdc_time_offset_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_int64 t64; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -1020,30 +1216,42 @@ cc_int_ccache_set_kdc_time_offset( cc_ccache_t ccache, request_header = (ccmsg_ccache_set_kdc_time_offset_t*)malloc(sizeof(ccmsg_ccache_set_kdc_time_offset_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; - request_header->creds_version = credentials_version; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); + request_header->creds_version = htonl(credentials_version); + t64 = time_offset; + request_header->offset = htonll(t64); code = cci_msg_new(ccmsg_CCACHE_SET_KDC_TIME_OFFSET, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_set_kdc_time_offset_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -1051,11 +1259,12 @@ cc_int32 cc_int_ccache_clear_kdc_time_offset( cc_ccache_t ccache, cc_int32 credentials_version ) { - cc_int_ccache_t int_ccache; - cc_msg_t *request; - ccmsg_ccache_clear_kdc_time_offset_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_t int_ccache; + cc_msg_t *request = NULL; + ccmsg_ccache_clear_kdc_time_offset_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -1068,31 +1277,39 @@ cc_int_ccache_clear_kdc_time_offset( cc_ccache_t ccache, request_header = (ccmsg_ccache_clear_kdc_time_offset_t*)malloc(sizeof(ccmsg_ccache_clear_kdc_time_offset_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_ccache->ctx; - request_header->ccache = int_ccache->handle; - request_header->creds_version = credentials_version; + request_header->ctx = htonll(int_ccache->ctx); + request_header->ccache = htonll(int_ccache->handle); + request_header->creds_version = htonl(credentials_version); code = cci_msg_new(ccmsg_CCACHE_CLEAR_KDC_TIME_OFFSET, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_clear_kdc_time_offset_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } - - diff --git a/src/lib/ccapi/client/ccache.h b/src/lib/ccapi/client/ccache.h index e3b3993ee0..0a92ebf63d 100644 --- a/src/lib/ccapi/client/ccache.h +++ b/src/lib/ccapi/client/ccache.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -114,11 +114,11 @@ cc_int_ccache_unlock( cc_ccache_t ccache ); cc_int32 cc_int_ccache_get_last_default_time( cc_ccache_t ccache, - cc_time_t* time ); + cc_time* time ); cc_int32 cc_int_ccache_get_change_time( cc_ccache_t ccache, - cc_time_t* time ); + cc_time* time ); cc_int32 cc_int_ccache_compare( cc_ccache_t ccache, @@ -128,12 +128,12 @@ cc_int_ccache_compare( cc_ccache_t ccache, cc_int32 cc_int_ccache_get_kdc_time_offset( cc_ccache_t ccache, cc_int32 credentials_version, - cc_time_t* time_offset ); + cc_time* time_offset ); cc_int32 cc_int_ccache_set_kdc_time_offset( cc_ccache_t ccache, cc_int32 credentials_version, - cc_time_t time_offset ); + cc_time time_offset ); cc_int32 cc_int_ccache_clear_kdc_time_offset( cc_ccache_t ccache, diff --git a/src/lib/ccapi/client/ccache_iterator.c b/src/lib/ccapi/client/ccache_iterator.c index 03266b1bbe..3da9b35478 100644 --- a/src/lib/ccapi/client/ccache_iterator.c +++ b/src/lib/ccapi/client/ccache_iterator.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -46,7 +46,9 @@ #include #include #include +#include "ccache.h" #include "ccache_iterator.h" +#include "cc_rpc.h" #include "msg.h" #include "msg_headers.h" @@ -56,7 +58,7 @@ cc_int_ccache_iterator_new( cc_ccache_iterator_t * piter, cc_handle ctx, cc_handle handle ) { - cc_int_ccache_iterator_t iter; + cc_int_ccache_iterator_t iter = NULL; if ( piter == NULL ) return ccErrBadParam; @@ -66,7 +68,7 @@ cc_int_ccache_iterator_new( cc_ccache_iterator_t * piter, return ccErrNoMem; iter->functions = (cc_ccache_iterator_f*)malloc( sizeof(cc_ccache_iterator_f)); - if ( iter->functions ) { + if ( iter->functions == NULL ) { free(iter); return ccErrNoMem; } @@ -84,11 +86,12 @@ cc_int_ccache_iterator_new( cc_ccache_iterator_t * piter, cc_int32 cc_int_ccache_iterator_release( cc_ccache_iterator_t iter ) { - cc_int_ccache_iterator_t int_iter; - cc_msg_t *request; - ccmsg_ccache_iterator_release_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_iterator_t int_iter; + cc_msg_t *request = NULL; + ccmsg_ccache_iterator_release_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( iter == NULL ) @@ -102,31 +105,43 @@ cc_int_ccache_iterator_release( cc_ccache_iterator_t iter ) request_header = (ccmsg_ccache_iterator_release_t*)malloc(sizeof(ccmsg_ccache_iterator_release_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_iter->ctx; - request_header->iterator = int_iter->handle; + request_header->ctx = htonll(int_iter->ctx); + request_header->iterator = htonll(int_iter->handle); code = cci_msg_new(ccmsg_CCACHE_ITERATOR_RELEASE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_iterator_release_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); - free(int_iter->functions); - free(int_iter); + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); + + if (int_iter->functions) + free(int_iter->functions); + if (iter) + free(int_iter); return ccNoError; } @@ -134,11 +149,12 @@ cc_int32 cc_int_ccache_iterator_next( cc_ccache_iterator_t iter, cc_ccache_t * ccache ) { - cc_int_ccache_iterator_t int_iter; - cc_msg_t *request; - ccmsg_ccache_iterator_next_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_ccache_iterator_t int_iter; + cc_msg_t *request = NULL; + ccmsg_ccache_iterator_next_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( ccache == NULL ) return ccErrBadParam; @@ -151,29 +167,98 @@ cc_int_ccache_iterator_next( cc_ccache_iterator_t iter, request_header = (ccmsg_ccache_iterator_next_t*)malloc(sizeof(ccmsg_ccache_iterator_next_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_iter->ctx; - request_header->iterator = int_iter->handle; + request_header->ctx = htonll(int_iter->ctx); + request_header->iterator = htonll(int_iter->handle); code = cci_msg_new(ccmsg_CCACHE_ITERATOR_NEXT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_iterator_next_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + } else if (type == ccmsg_ACK) { ccmsg_ccache_iterator_next_resp_t * response_header = (ccmsg_ccache_iterator_next_resp_t*)response->header; - code = cc_ccache_new(ccache, int_iter->ctx, response_header->ccache); + code = cc_int_ccache_new(ccache, int_iter->ctx, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); + return code; +} + +cc_int32 +cc_int_ccache_iterator_clone( cc_ccache_iterator_t iter, + cc_ccache_iterator_t * new_iter ) +{ + cc_int_ccache_iterator_t int_iter; + cc_msg_t *request = NULL; + ccmsg_ccache_iterator_clone_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; + + if ( iter == NULL || new_iter == NULL ) + return ccErrBadParam; + + int_iter = (cc_int_ccache_iterator_t)iter; + + if ( int_iter->magic != CC_CCACHE_ITER_MAGIC ) + return ccErrInvalidCCacheIterator; + + request_header = (ccmsg_ccache_iterator_clone_t*)malloc(sizeof(ccmsg_ccache_iterator_clone_t)); + if (request_header == NULL) + return ccErrNoMem; + request_header->ctx = htonll(int_iter->ctx); + request_header->iterator = htonll(int_iter->handle); + + code = cci_msg_new(ccmsg_CCACHE_ITERATOR_CLONE, &request); + if (code != ccNoError) + goto cleanup; + + code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_iterator_clone_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; + + code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; + + type = ntohl(response->type); + if (type == ccmsg_NACK) { + ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { + ccmsg_ccache_iterator_clone_resp_t * response_header = (ccmsg_ccache_iterator_clone_resp_t*)response->header; + code = cc_int_ccache_iterator_new(new_iter, int_iter->ctx, ntohll(response_header->iterator)); + } else { + code = ccErrBadInternalMessage; + } + + cleanup: + if (request_header) + free(request); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } diff --git a/src/lib/ccapi/client/ccache_iterator.h b/src/lib/ccapi/client/ccache_iterator.h index c55d72ee67..5a390b82ed 100644 --- a/src/lib/ccapi/client/ccache_iterator.h +++ b/src/lib/ccapi/client/ccache_iterator.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -73,6 +73,10 @@ cc_int32 cc_int_ccache_iterator_next( cc_ccache_iterator_t iter, cc_ccache_t * ccache ); +cc_int32 +cc_int_ccache_iterator_clone( cc_ccache_iterator_t iter, + cc_ccache_iterator_t * iter_new ); + cc_int32 cc_int_ccache_iterator_set_repeat_count( cc_int_ccache_iterator_t iter, cc_uint32 count ); diff --git a/src/lib/ccapi/client/ccapiv2.c b/src/lib/ccapi/client/ccapiv2.c new file mode 100644 index 0000000000..82b04c2c8e --- /dev/null +++ b/src/lib/ccapi/client/ccapiv2.c @@ -0,0 +1,295 @@ +/* $Copyright: + * + * Copyright 1998-2006 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 MIT 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. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Individual source code files are copyright MIT, Cygnus Support, + * OpenVision, Oracle, Sun Soft, FundsXpress, and others. + * + * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, + * and Zephyr are trademarks of the Massachusetts Institute of Technology + * (MIT). No commercial use of these trademarks may be made without prior + * written permission of MIT. + * + * "Commercial use" means use of a name in a product or other for-profit + * manner. It does NOT prevent a commercial firm from referring to the MIT + * trademarks in order to convey information (although in doing so, + * recognition of their trademark status should be given). + * $ + */ +/* + * This is backwards compatibility for CCache API v2 clients to be able to run + * against the CCache API v3 library + */ + +#include "CredentialsCache2.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +CCACHE_API cc_int32 cc_shutdown ( + apiCB** ioContext) +{ + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_get_NC_info ( + apiCB* inContext, + infoNC*** outInfo) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_get_change_time ( + apiCB* inContext, + cc_time* outTime) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_open ( + apiCB* inContext, + const char* inName, + cc_int32 inVersion, + cc_uint32 inFlags, + ccache_p** outCCache) +{ + if (inVersion != CC_CRED_V4 && inVersion != CC_CRED_V5) + return CC_ERR_CRED_VERSION; + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_create ( + apiCB* inContext, + const char* inName, + const char* inPrincipal, + cc_int32 inVersion, + cc_uint32 inFlags, + ccache_p** outCCache) +{ + if (inVersion != CC_CRED_V4 && inVersion != CC_CRED_V5) + return CC_ERR_CRED_VERSION; + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_close ( + apiCB* inContext, + ccache_p** ioCCache) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_destroy ( + apiCB* inContext, + ccache_p** ioCCache) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_seq_fetch_NCs_begin ( + apiCB* inContext, + ccache_cit** outIterator) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_seq_fetch_NCs_next ( + apiCB* inContext, + ccache_p** outCCache, + ccache_cit* inIterator) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_seq_fetch_NCs_end ( + apiCB* inContext, + ccache_cit** ioIterator) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_get_name ( + apiCB* inContext, + ccache_p* inCCache, + char** outName) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_get_cred_version ( + apiCB* inContext, + ccache_p* inCCache, + cc_int32* outVersion) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_set_principal ( + apiCB* inContext, + ccache_p* inCCache, + cc_int32 inVersion, + char* inPrincipal) +{ + if (inVersion != CC_CRED_V4 && inVersion != CC_CRED_V5) + return CC_ERR_CRED_VERSION; + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_get_principal ( + apiCB* inContext, + ccache_p* inCCache, + char** outPrincipal) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_store ( + apiCB* inContext, + ccache_p* inCCache, + cred_union inCredentials) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_remove_cred ( + apiCB* inContext, + ccache_p* inCCache, + cred_union inCredentials) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_seq_fetch_creds_begin ( + apiCB* inContext, + const ccache_p* inCCache, + ccache_cit** outIterator) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_seq_fetch_creds_next ( + apiCB* inContext, + cred_union** outCreds, + ccache_cit* inIterator) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_seq_fetch_creds_end ( + apiCB* inContext, + ccache_cit** ioIterator) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_free_principal ( + apiCB* inContext, + char** ioPrincipal) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_free_name ( + apiCB* inContext, + char** ioName) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_free_creds ( + apiCB* inContext, + cred_union** creds) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_free_NC_info ( + apiCB* inContext, + infoNC*** ioInfo) +{ + + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + +CCACHE_API cc_int32 cc_lock_request( + apiCB* inContext, + const ccache_p* inCCache, + const cc_int32 lock_type) +{ + /* replace this return value when the function is implemented */ + return CC_NOT_SUPP; +} + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + diff --git a/src/lib/ccapi/client/ccstring.c b/src/lib/ccapi/client/ccstring.c index 419bfef772..6f3fa2bcbf 100644 --- a/src/lib/ccapi/client/ccstring.c +++ b/src/lib/ccapi/client/ccstring.c @@ -50,9 +50,9 @@ #include "ccstring.h" cc_int32 -cc_int_string_new( cc_string_t * pstring, char * data ) +cci_string_new( cc_string_t * pstring, char * data ) { - cc_int_string_t string = (cc_int_string_t)malloc(sizeof(cc_int_string_d)); + cci_string_t string = (cci_string_t)malloc(sizeof(cci_string_d)); if ( string == NULL ) return ccErrNoMem; @@ -63,7 +63,7 @@ cc_int_string_new( cc_string_t * pstring, char * data ) } string->magic = CC_STRING_MAGIC; - string->functions->release = cc_int_string_release; + string->functions->release = cci_string_release; string->data = strdup(data); if ( string->data == NULL ) { @@ -77,13 +77,13 @@ cc_int_string_new( cc_string_t * pstring, char * data ) } cc_int32 -cc_int_string_release( cc_string_t str ) +cci_string_release( cc_string_t str ) { - cc_int_string_t int_string; + cci_string_t int_string; if ( str == NULL ) return ccErrBadParam; - int_string = (cc_int_string_t)str; + int_string = (cci_string_t)str; if ( int_string->magic != CC_STRING_MAGIC ) return ccErrInvalidString; diff --git a/src/lib/ccapi/client/ccstring.h b/src/lib/ccapi/client/ccstring.h index 9e0ad223f5..2c973afbb5 100644 --- a/src/lib/ccapi/client/ccstring.h +++ b/src/lib/ccapi/client/ccstring.h @@ -45,7 +45,7 @@ #define CC_STRING_MAGIC ('S'<<24 | 'T'<<16 | 'R'<<8 | 'I') -struct cc_int_string_d { +struct cci_string_d { char* data; cc_string_f* functions; #if TARGET_OS_MAC @@ -53,13 +53,13 @@ struct cc_int_string_d { #endif cc_uint32 magic; }; -typedef struct cc_int_string_d cc_int_string_d; -typedef cc_int_string_d* cc_int_string_t; +typedef struct cci_string_d cci_string_d; +typedef cci_string_d* cci_string_t; cc_int32 -cc_int_string_new( cc_string_t * pstring, char * data ); +cci_string_new( cc_string_t * pstring, char * data ); cc_int32 -cc_int_string_release( cc_string_t string ); +cci_string_release( cc_string_t string ); diff --git a/src/lib/ccapi/client/context.c b/src/lib/ccapi/client/context.c index 86c41b8e70..5d88d46868 100644 --- a/src/lib/ccapi/client/context.c +++ b/src/lib/ccapi/client/context.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -45,10 +45,20 @@ #include #include +#include #include #include "context.h" +#include "ccache.h" +#include "ccache_iterator.h" +#include "cc_rpc.h" #include "msg.h" #include "msg_headers.h" +#include "ccstring.h" + +/* cc_int_context_new + * + * input parameters (handle, version) are in host order + */ cc_int32 cc_int_context_new( cc_context_t * pcontext, cc_handle handle, cc_uint32 version ) @@ -87,11 +97,12 @@ cc_int_context_new( cc_context_t * pcontext, cc_handle handle, cc_uint32 version cc_int32 cc_int_context_release( cc_context_t context ) { - cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ctx_release_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_context_t int_context; + cc_msg_t *request = NULL; + ccmsg_ctx_release_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( context == NULL ) return ccErrBadParam; @@ -104,28 +115,38 @@ cc_int_context_release( cc_context_t context ) request_header = (ccmsg_ctx_release_t*)malloc(sizeof(ccmsg_ctx_release_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_context->handle; + request_header->ctx = htonll(int_context->handle); code = cci_msg_new(ccmsg_CTX_RELEASE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_release_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + request_header = NULL; + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); free(int_context->functions); free(int_context); return code; @@ -133,14 +154,16 @@ cc_int_context_release( cc_context_t context ) cc_int32 cc_int_context_get_change_time( cc_context_t context, - cc_time_t* time) + cc_time* time) { - cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ctx_get_change_time_t *request_header; - cc_msg_t *response; + cc_int_context_t int_context; + cc_msg_t *request = NULL; + ccmsg_ctx_get_change_time_t *request_header = NULL; + cc_msg_t *response = NULL; ccmsg_ctx_get_change_time_resp_t *response_header; - cc_int32 code; + cc_time64 t64; + cc_uint32 type; + cc_int32 code; if ( context == NULL || time == NULL ) return ccErrBadParam; @@ -153,30 +176,42 @@ cc_int_context_get_change_time( cc_context_t context, request_header = (ccmsg_ctx_get_change_time_t*)malloc(sizeof(ccmsg_ctx_get_change_time_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_context->handle; + request_header->ctx = htonll(int_context->handle); code = cci_msg_new(ccmsg_CTX_GET_CHANGE_TIME, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_get_change_time_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; + code = ntohl(nack_header->err_code); } else if (response->type == ccmsg_ACK) { response_header = (ccmsg_ctx_get_change_time_resp_t*)response->header; - *time = response_header->time; + t64 = ntohll(response_header->time); + /* TODO: validate that value is not greater than can fit in cc_time */ + *time = (cc_time)t64; code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -184,12 +219,14 @@ cc_int32 cc_int_context_get_default_ccache_name( cc_context_t context, cc_string_t* name ) { - cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ctx_get_default_ccache_name_t *request_header; - cc_msg_t *response; + cc_int_context_t int_context; + cc_msg_t *request = NULL; + ccmsg_ctx_get_default_ccache_name_t *request_header = NULL; + cc_msg_t *response = NULL; ccmsg_ctx_get_default_ccache_name_resp_t *response_header; - cc_int32 code; + char *string = NULL; + cc_uint32 type; + cc_int32 code; if ( context == NULL || name == NULL ) return ccErrBadParam; @@ -202,35 +239,44 @@ cc_int_context_get_default_ccache_name( cc_context_t context, request_header = (ccmsg_ctx_get_default_ccache_name_t*)malloc(sizeof(ccmsg_ctx_get_default_ccache_name_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_context->handle; + request_header->ctx = htonll(int_context->handle); code = cci_msg_new(ccmsg_CTX_GET_DEFAULT_CCACHE_NAME, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_get_default_ccache_name_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { - char * string; + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_ctx_get_default_ccache_name_resp_t*)response->header; code = cci_msg_retrieve_blob(response, response_header->name_offset, response_header->name_len, &string); - if (code == ccNoError) { - code = cc_string_new(&name, string); - free(string); - } + if (code == ccNoError) + code = cci_string_new(name, string); } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (string) + free(string); + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -240,11 +286,12 @@ cc_int_context_compare( cc_context_t context, cc_uint32* equal ) { cc_int_context_t int_context, int_compare_to; - cc_msg_t *request; - ccmsg_ctx_compare_t *request_header; - cc_msg_t *response; + cc_msg_t *request = NULL; + ccmsg_ctx_compare_t *request_header = NULL; + cc_msg_t *response = NULL; ccmsg_ctx_compare_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || compare_to == NULL || equal == NULL ) @@ -260,31 +307,41 @@ cc_int_context_compare( cc_context_t context, request_header = (ccmsg_ctx_compare_t*)malloc(sizeof(ccmsg_ctx_compare_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx1 = int_context->handle; - request_header->ctx2 = int_compare_to->handle; + request_header->ctx1 = htonll(int_context->handle); + request_header->ctx2 = htonll(int_compare_to->handle); code = cci_msg_new(ccmsg_CTX_COMPARE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_compare_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_ctx_compare_resp_t*)response->header; - *equal = response_header->is_equal; + *equal = ntohl(response_header->is_equal); code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -293,12 +350,13 @@ cc_int32 cc_int_context_new_ccache_iterator( cc_context_t context, cc_ccache_iterator_t* iterator ) { - cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ctx_new_ccache_iterator_t *request_header; - cc_msg_t *response; + cc_int_context_t int_context; + cc_msg_t *request = NULL; + ccmsg_ctx_new_ccache_iterator_t *request_header = NULL; + cc_msg_t *response = NULL; ccmsg_ctx_new_ccache_iterator_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || iterator == NULL ) return ccErrBadParam; @@ -311,29 +369,40 @@ cc_int_context_new_ccache_iterator( cc_context_t context, request_header = (ccmsg_ctx_new_ccache_iterator_t*)malloc(sizeof(ccmsg_ctx_new_ccache_iterator_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_context->handle; + request_header->ctx = htonll(int_context->handle); code = cci_msg_new(ccmsg_CTX_NEW_CCACHE_ITERATOR, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_new_ccache_iterator_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_ctx_new_ccache_iterator_resp_t*)response->header; - code = cc_int_ccache_iterator_new(iterator, int_context->handle, response_header->iterator); + code = cc_int_ccache_iterator_new(iterator, int_context->handle, + ntohll(response_header->iterator)); } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -342,13 +411,14 @@ cc_int_context_open_ccache( cc_context_t context, const char* name, cc_ccache_t* ccache ) { - cc_uint32 blob_pos; - cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ccache_open_t *request_header; - cc_msg_t *response; + cc_uint32 blob_pos; + cc_int_context_t int_context; + cc_msg_t *request = NULL; + ccmsg_ccache_open_t *request_header = NULL; + cc_msg_t *response = NULL; ccmsg_ccache_open_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || name == NULL || ccache == NULL ) return ccErrBadParam; @@ -362,38 +432,45 @@ cc_int_context_open_ccache( cc_context_t context, if (request_header == NULL) return ccErrNoMem; - code = cci_msg_new(ccmsg_CCACHE_OPEN, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + code = cci_msg_new(ccmsg_CTX_CCACHE_OPEN, &request); + if (code != ccNoError) + goto cleanup; code = cci_msg_add_data_blob(request, (void *)name, strlen(name) + 1, &blob_pos); - if (code != ccNoError) { - cci_msg_destroy(request); - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; - request_header->ctx = int_context->handle; - request_header->name_offset = blob_pos; - request_header->name_len = strlen(name) + 1; + request_header->ctx = htonll(int_context->handle); + request_header->name_offset = htonl(blob_pos); + request_header->name_len = htonl(strlen(name) + 1); code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_open_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_open_resp_t*)response->header; - code = cc_cache_new(ccache, response_header->ccache); + code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -401,12 +478,13 @@ cc_int32 cc_int_context_open_default_ccache( cc_context_t context, cc_ccache_t* ccache) { - cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ccache_open_default_t *request_header; - cc_msg_t *response; + cc_int_context_t int_context; + cc_msg_t *request = NULL; + ccmsg_ccache_open_default_t *request_header = NULL; + cc_msg_t *response = NULL; ccmsg_ccache_open_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || ccache == NULL ) return ccErrBadParam; @@ -420,29 +498,39 @@ cc_int_context_open_default_ccache( cc_context_t context, if (request_header == NULL) return ccErrNoMem; - code = cci_msg_new(ccmsg_CCACHE_OPEN_DEFAULT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + code = cci_msg_new(ccmsg_CTX_CCACHE_OPEN_DEFAULT, &request); + if (code != ccNoError) + goto cleanup; - request_header->ctx = int_context->handle; + request_header->ctx = htonll(int_context->handle); code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_open_default_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_open_resp_t*)response->header; - code = cc_cache_new(ccache, response_header->ccache); + code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -453,13 +541,14 @@ cc_int_context_create_ccache( cc_context_t context, const char* principal, cc_ccache_t* ccache ) { - cc_uint32 blob_pos; - cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ccache_create_t *request_header; - cc_msg_t *response; + cc_uint32 blob_pos; + cc_int_context_t int_context; + cc_msg_t *request = NULL; + ccmsg_ccache_create_t *request_header = NULL; + cc_msg_t *response = NULL; ccmsg_ccache_create_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || name == NULL || cred_vers == 0 || cred_vers > cc_credentials_v4_v5 || @@ -475,48 +564,53 @@ cc_int_context_create_ccache( cc_context_t context, if (request_header == NULL) return ccErrNoMem; - code = cci_msg_new(ccmsg_CCACHE_CREATE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + code = cci_msg_new(ccmsg_CTX_CCACHE_CREATE, &request); + if (code != ccNoError) + goto cleanup; code = cci_msg_add_data_blob(request, (void *)name, strlen(name) + 1, &blob_pos); - if (code != ccNoError) { - cci_msg_destroy(request); - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; - request_header->ctx = int_context->handle; - request_header->version = cred_vers; - request_header->name_offset = blob_pos; - request_header->name_len = strlen(name) + 1; + request_header->ctx = htonll(int_context->handle); + request_header->version = htonl(cred_vers); + request_header->name_offset = htonl(blob_pos); + request_header->name_len = htonl(strlen(name) + 1); code = cci_msg_add_data_blob(request, (void *)principal, strlen(principal) + 1, &blob_pos); - if (code != ccNoError) { - cci_msg_destroy(request); - free(request_header); - return code; - } - request_header->principal_offset = blob_pos; - request_header->principal_len = strlen(principal) + 1; + if (code != ccNoError) + goto cleanup; + + request_header->principal_offset = htonl(blob_pos); + request_header->principal_len = htonl(strlen(principal) + 1); code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_create_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_create_resp_t*)response->header; - code = cc_cache_new(ccache, response_header->ccache); + code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -526,13 +620,14 @@ cc_int_context_create_default_ccache( cc_context_t context, const char* principal, cc_ccache_t* ccache ) { - cc_uint32 blob_pos; - cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ccache_create_default_t *request_header; - cc_msg_t *response; + cc_uint32 blob_pos; + cc_int_context_t int_context; + cc_msg_t *request = NULL; + ccmsg_ccache_create_default_t *request_header = NULL; + cc_msg_t *response = NULL; ccmsg_ccache_create_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || cred_vers == 0 || cred_vers > cc_credentials_v4_v5 || @@ -548,39 +643,47 @@ cc_int_context_create_default_ccache( cc_context_t context, if (request_header == NULL) return ccErrNoMem; - code = cci_msg_new(ccmsg_CCACHE_CREATE_DEFAULT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + code = cci_msg_new(ccmsg_CTX_CCACHE_CREATE_DEFAULT, &request); + if (code != ccNoError) + goto cleanup; - request_header->ctx = int_context->handle; - request_header->version = cred_vers; + request_header->ctx = htonll(int_context->handle); + request_header->version = htonl(cred_vers); code = cci_msg_add_data_blob(request, (void *)principal, strlen(principal) + 1, &blob_pos); - if (code != ccNoError) { - cci_msg_destroy(request); - free(request_header); - return code; - } - request_header->principal_offset = blob_pos; - request_header->principal_len = strlen(principal) + 1; + if (code != ccNoError) + goto cleanup; + + request_header->principal_offset = htonl(blob_pos); + request_header->principal_len = htonl(strlen(principal) + 1); code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_create_default_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_create_resp_t*)response->header; - code = cc_cache_new(ccache, response_header->ccache); + code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -590,13 +693,14 @@ cc_int_context_create_new_ccache( cc_context_t context, const char* principal, cc_ccache_t* ccache ) { - cc_uint32 blob_pos; - cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ccache_create_unique_t *request_header; - cc_msg_t *response; + cc_uint32 blob_pos; + cc_int_context_t int_context; + cc_msg_t *request = NULL; + ccmsg_ccache_create_unique_t *request_header = NULL; + cc_msg_t *response = NULL; ccmsg_ccache_create_resp_t *response_header; - cc_int32 code; + cc_uint32 type; + cc_int32 code; if ( context == NULL || cred_vers == 0 || cred_vers > cc_credentials_v4_v5 || @@ -612,39 +716,47 @@ cc_int_context_create_new_ccache( cc_context_t context, if (request_header == NULL) return ccErrNoMem; - code = cci_msg_new(ccmsg_CCACHE_CREATE_UNIQUE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + code = cci_msg_new(ccmsg_CTX_CCACHE_CREATE_UNIQUE, &request); + if (code != ccNoError) + goto cleanup; - request_header->ctx = int_context->handle; - request_header->version = cred_vers; + request_header->ctx = htonll(int_context->handle); + request_header->version = htonl(cred_vers); code = cci_msg_add_data_blob(request, (void *)principal, strlen(principal) + 1, &blob_pos); - if (code != ccNoError) { - cci_msg_destroy(request); - free(request_header); - return code; - } - request_header->principal_offset = blob_pos; - request_header->principal_len = strlen(principal) + 1; + if (code != ccNoError) + goto cleanup; + + request_header->principal_offset = htonl(blob_pos); + request_header->principal_len = htonl(strlen(principal) + 1); code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ccache_create_unique_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = htonl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { response_header = (ccmsg_ccache_create_resp_t*)response-> header; - code = cc_cache_new(ccache, response_header->ccache); + code = cc_int_ccache_new(ccache, int_context->handle, ntohll(response_header->ccache)); } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -653,14 +765,16 @@ cc_int_context_lock( cc_context_t context, cc_uint32 lock_type, cc_uint32 block ) { - cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ctx_lock_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_context_t int_context; + cc_msg_t *request = NULL; + ccmsg_ctx_lock_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( context == NULL || - (lock_type != cc_lock_read && lock_type != cc_lock_write) || + (lock_type != cc_lock_read && lock_type != cc_lock_write && + lock_type != cc_lock_upgrade && lock_type != cc_lock_downgrade) || (block != cc_lock_block && block != cc_lock_noblock) ) return ccErrBadParam; @@ -674,41 +788,52 @@ cc_int_context_lock( cc_context_t context, return ccErrNoMem; code = cci_msg_new(ccmsg_CTX_LOCK, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; - request_header->ctx = int_context->handle; - request_header->lock_type; + request_header->ctx = htonll(int_context->handle); + request_header->lock_type = htonl(lock_type); code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_lock_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; + code = ntohl(nack_header->err_code); // TODO: if (block == cc_lock_block) ..... - } else if (response->type == ccmsg_ACK) { + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } cc_int32 cc_int_context_unlock( cc_context_t context ) { - cc_int_context_t int_context; - cc_msg_t *request; - ccmsg_ctx_unlock_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_int_context_t int_context; + cc_msg_t *request = NULL; + ccmsg_ctx_unlock_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( context == NULL ) return ccErrBadParam; @@ -723,27 +848,37 @@ cc_int_context_unlock( cc_context_t context ) return ccErrNoMem; code = cci_msg_new(ccmsg_CTX_UNLOCK, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; - request_header->ctx = int_context->handle; + request_header->ctx = htonll(int_context->handle); code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_unlock_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -754,20 +889,22 @@ cc_int_context_clone( cc_context_t inContext, cc_int32* supportedVersion, char const** vendor ) { - cc_int_context_t int_context, new_context; - static char vendor_st[128] = ""; - cc_msg_t *request; - ccmsg_clone_t *request_header; - cc_msg_t *response; - ccmsg_clone_resp_t *response_header; - cc_int32 code; + cc_int_context_t int_context; + static char vendor_st[128] = ""; + cc_msg_t *request = NULL; + ccmsg_ctx_clone_t *request_header = NULL; + cc_msg_t *response = NULL; + ccmsg_ctx_clone_resp_t *response_header; + char *string = NULL; + cc_uint32 type; + cc_int32 code; if ( inContext == NULL || outContext == NULL || supportedVersion == NULL ) return ccErrBadParam; - int_context = (cc_int_context_t)context; + int_context = (cc_int_context_t)inContext; if ( int_context->magic != CC_CONTEXT_MAGIC ) return ccErrInvalidContext; @@ -775,45 +912,48 @@ cc_int_context_clone( cc_context_t inContext, if ((requestedVersion != ccapi_version_2) && (requestedVersion != ccapi_version_3) && (requestedVersion != ccapi_version_4) && - (requestedVersion != ccapi_version_5)) { + (requestedVersion != ccapi_version_5) && + (requestedVersion != ccapi_version_6)) { if (supportedVersion != NULL) { - *supportedVersion = ccapi_version_5; + *supportedVersion = ccapi_version_max; } return ccErrBadAPIVersion; } - request_header = (ccmsg_clone_t*)malloc(sizeof(ccmsg_clone_t)); + request_header = (ccmsg_ctx_clone_t*)malloc(sizeof(ccmsg_ctx_clone_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_context->handle; - request_header->in_version = requestedVersion; + request_header->ctx = htonll(int_context->handle); + request_header->in_version = htonl(requestedVersion); code = cci_msg_new(ccmsg_INIT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; - code = cci_msg_add_header(request, request_header, sizeof(ccmsg_init_t)); + code = cci_msg_add_header(request, request_header, sizeof(ccmsg_ctx_clone_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { - response_header = (ccmsg_clone_resp_t *)response->header; - *supportedVersion = response_header->out_version; - code = cc_int_context_new(outContext, response_header->out_ctx, response_header->out_version); + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { + response_header = (ccmsg_ctx_clone_resp_t *)response->header; + *supportedVersion = ntohl(response_header->out_version); + code = cc_int_context_new(outContext, ntohll(response_header->out_ctx), ntohl(response_header->out_version)); if (!vendor_st[0]) { - char * string; - code = cci_msg_retrieve_blob(response, response_header->vendor_offset, response_header->vendor_length, &string); + code = cci_msg_retrieve_blob(response, ntohl(response_header->vendor_offset), ntohl(response_header->vendor_length), &string); strncpy(vendor_st, string, sizeof(vendor_st)-1); vendor_st[sizeof(vendor_st)-1] = '\0'; - free(string); } *vendor = vendor_st; @@ -821,8 +961,16 @@ cc_int_context_clone( cc_context_t inContext, } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (string) + free(string); + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } @@ -831,7 +979,6 @@ cc_int_context_get_version( cc_context_t context, cc_int32* version ) { cc_int_context_t int_context; - cc_int32 code; if ( context == NULL || version == NULL ) diff --git a/src/lib/ccapi/client/context.h b/src/lib/ccapi/client/context.h index cd5ca678d4..6ff113a269 100644 --- a/src/lib/ccapi/client/context.h +++ b/src/lib/ccapi/client/context.h @@ -66,7 +66,7 @@ cc_int_context_release( cc_context_t context ); cc_int32 cc_int_context_get_change_time( cc_context_t context, - cc_time_t* time); + cc_time* time); cc_int32 cc_int_context_get_default_ccache_name( cc_context_t context, diff --git a/src/lib/ccapi/client/credentials.c b/src/lib/ccapi/client/credentials.c index b0a3df2b75..dbdf6345e8 100644 --- a/src/lib/ccapi/client/credentials.c +++ b/src/lib/ccapi/client/credentials.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -88,10 +88,10 @@ cc_int_credentials_new( cc_credentials_t *pcredentials, cc_uint32 version, switch ( version ) { case cc_credentials_v4: - code = cci_cred_v4_unmarshall(data, len, credentials->data); + code = cci_creds_v4_unmarshall(data, len, credentials->data); break; case cc_credentials_v5: - code = cci_cred_v5_unmarshall(data, len, credentials->data); + code = cci_creds_v5_unmarshall(data, len, credentials->data); break; default: free(credentials); @@ -159,23 +159,23 @@ cc_int_credentials_release( cc_credentials_t creds ) cc_int32 cc_int_credentials_compare( cc_credentials_t credentials, - cc_credentials_t compare_to, - cc_uint32* equal ) + cc_credentials_t compare_to, + cc_uint32* equal ) { cc_int_credentials_t int_credentials; cc_int_credentials_t int_compare_to; if ( credentials == NULL || compare_to == NULL || equal == NULL ) return ccErrBadParam; - + int_credentials = (cc_int_credentials_t)credentials; + int_compare_to = (cc_int_credentials_t)compare_to; + if ( int_credentials->magic != CC_CREDS_MAGIC || int_compare_to->magic != CC_CREDS_MAGIC ) return ccErrInvalidCredentials; - int_credentials = (cc_int_credentials_t)credentials; - int_compare_to = (cc_int_credentials_t)compare_to; - *equal = (int_credentials->handle == int_compare_to->handle); + return ccNoError; } diff --git a/src/lib/ccapi/client/credentials.h b/src/lib/ccapi/client/credentials.h index 320c618257..dfd589f326 100644 --- a/src/lib/ccapi/client/credentials.h +++ b/src/lib/ccapi/client/credentials.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -84,8 +84,8 @@ cci_creds_v5_marshall( cc_credentials_v5_t * creds, cc_int32 cci_creds_v4_unmarshall( char * flat, - cc_uint32 len, - cc_credentials_union * creds); + cc_uint32 len, + cc_credentials_union * creds); cc_int32 cci_creds_v5_unmarshall( char * flat, diff --git a/src/lib/ccapi/client/credentials_iterator.c b/src/lib/ccapi/client/credentials_iterator.c index b7333daf30..3cdab875a3 100644 --- a/src/lib/ccapi/client/credentials_iterator.c +++ b/src/lib/ccapi/client/credentials_iterator.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -46,7 +46,9 @@ #include #include #include +#include "credentials.h" #include "credentials_iterator.h" +#include "cc_rpc.h" #include "msg.h" #include "msg_headers.h" @@ -74,6 +76,7 @@ cc_int_credentials_iterator_new( cc_credentials_iterator_t * piter, iter->functions->release = cc_int_credentials_iterator_release; iter->functions->next = cc_int_credentials_iterator_next; + iter->functions->clone = cc_int_credentials_iterator_clone; iter->magic = CC_CREDS_ITER_MAGIC; iter->ctx = ctx; iter->ccache = ccache; @@ -87,10 +90,11 @@ cc_int32 cc_int_credentials_iterator_release( cc_credentials_iterator_t iter ) { cc_int_credentials_iterator_t int_iter; - cc_msg_t *request; - ccmsg_creds_iterator_release_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *request = NULL; + ccmsg_creds_iterator_release_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( iter == NULL ) return ccErrBadParam; @@ -103,29 +107,40 @@ cc_int_credentials_iterator_release( cc_credentials_iterator_t iter ) request_header = (ccmsg_creds_iterator_release_t*)malloc(sizeof(ccmsg_creds_iterator_release_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_iter->ctx; - request_header->ccache = int_iter->ccache; - request_header->iterator = int_iter->handle; + request_header->ctx = htonll(int_iter->ctx); + request_header->ccache = htonll(int_iter->ccache); + request_header->iterator = htonll(int_iter->handle); + code = cci_msg_new(ccmsg_CREDS_ITERATOR_RELEASE, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_creds_iterator_release_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = htonl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = htonl(nack_header->err_code); + } else if (type == ccmsg_ACK) { code = ccNoError; } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); free(int_iter->functions); free(int_iter); @@ -137,10 +152,11 @@ cc_int_credentials_iterator_next( cc_credentials_iterator_t iter, cc_credentials_t * credentials ) { cc_int_credentials_iterator_t int_iter; - cc_msg_t *request; - ccmsg_creds_iterator_next_t *request_header; - cc_msg_t *response; - cc_int32 code; + cc_msg_t *request = NULL; + ccmsg_creds_iterator_next_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; if ( credentials == NULL ) return ccErrBadParam; @@ -153,35 +169,105 @@ cc_int_credentials_iterator_next( cc_credentials_iterator_t iter, request_header = (ccmsg_creds_iterator_next_t*)malloc(sizeof(ccmsg_creds_iterator_next_t)); if (request_header == NULL) return ccErrNoMem; - request_header->ctx = int_iter->ctx; - request_header->ccache = int_iter->ccache; - request_header->iterator = int_iter->handle; + request_header->ctx = htonll(int_iter->ctx); + request_header->ccache = htonll(int_iter->ccache); + request_header->iterator = htonll(int_iter->handle); code = cci_msg_new(ccmsg_CREDS_ITERATOR_NEXT, &request); - if (code != ccNoError) { - free(request_header); - return code; - } + if (code != ccNoError) + goto cleanup; code = cci_msg_add_header(request, request_header, sizeof(ccmsg_creds_iterator_next_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; - if (response->type == ccmsg_NACK) { + type = ntohl(response->type); + if (type == ccmsg_NACK) { ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; - code = nack_header->err_code; - } else if (response->type == ccmsg_ACK) { + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { char * blob; ccmsg_creds_iterator_next_resp_t * response_header = (ccmsg_creds_iterator_next_resp_t*)response->header; - code = cci_msg_retrieve_blob(response, response_header->creds_offset, response_header->creds_len, &blob); - code = cc_credentials_new(credentials, response_header->version, - int_iter->ctx, int_iter->ccache, response_header->creds_handle, - blob, response_header->creds_len); + code = cci_msg_retrieve_blob(response, ntohl(response_header->creds_offset), ntohl(response_header->creds_len), &blob); + code = cc_int_credentials_new(credentials, ntohl(response_header->version), + int_iter->ctx, int_iter->ccache, ntohll(response_header->creds_handle), + blob, ntohl(response_header->creds_len)); free(blob); } else { code = ccErrBadInternalMessage; } - cci_msg_destroy(request); - cci_msg_destroy(response); + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); + return code; +} + +cc_int32 +cc_int_credentials_iterator_clone( cc_credentials_iterator_t iter, + cc_credentials_iterator_t* new_iter) +{ + cc_int_credentials_iterator_t int_iter; + cc_msg_t *request = NULL; + ccmsg_creds_iterator_clone_t *request_header = NULL; + cc_msg_t *response = NULL; + cc_uint32 type; + cc_int32 code; + + if ( iter == NULL || new_iter == NULL ) + return ccErrBadParam; + + int_iter = (cc_int_credentials_iterator_t)iter; + + if ( int_iter->magic != CC_CREDS_ITER_MAGIC ) + return ccErrInvalidCCacheIterator; + + request_header = (ccmsg_creds_iterator_clone_t*)malloc(sizeof(ccmsg_creds_iterator_clone_t)); + if (request_header == NULL) + return ccErrNoMem; + request_header->ctx = htonll(int_iter->ctx); + request_header->iterator = htonll(int_iter->handle); + + code = cci_msg_new(ccmsg_CREDS_ITERATOR_CLONE, &request); + if (code != ccNoError) + goto cleanup; + + code = cci_msg_add_header(request, request_header, sizeof(ccmsg_creds_iterator_clone_t)); + if (code != ccNoError) + goto cleanup; + request_header = NULL; + + code = cci_perform_rpc(request, &response); + if (code != ccNoError) + goto cleanup; + + type = ntohl(response->type); + if (type == ccmsg_NACK) { + ccmsg_nack_t * nack_header = (ccmsg_nack_t *)response->header; + code = ntohl(nack_header->err_code); + } else if (type == ccmsg_ACK) { + ccmsg_creds_iterator_clone_resp_t * response_header = (ccmsg_creds_iterator_clone_resp_t*)response->header; + code = cc_int_credentials_iterator_new(new_iter, int_iter->ctx, int_iter->ccache, ntohll(response_header->iterator)); + } else { + code = ccErrBadInternalMessage; + } + + cleanup: + if (request_header) + free(request_header); + if (request) + cci_msg_destroy(request); + if (response) + cci_msg_destroy(response); return code; } + diff --git a/src/lib/ccapi/client/credentials_iterator.h b/src/lib/ccapi/client/credentials_iterator.h index 2a6f8edf2d..954d2f1afa 100644 --- a/src/lib/ccapi/client/credentials_iterator.h +++ b/src/lib/ccapi/client/credentials_iterator.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -69,4 +69,8 @@ cc_int32 cc_int_credentials_iterator_next( cc_credentials_iterator_t iter, cc_credentials_t * credentials ); +cc_int32 +cc_int_credentials_iterator_clone( cc_credentials_iterator_t iter, + cc_credentials_iterator_t * new_iter ); + diff --git a/src/lib/ccapi/common/NTMakefile b/src/lib/ccapi/common/NTMakefile new file mode 100644 index 0000000000..a43985af3a --- /dev/null +++ b/src/lib/ccapi/common/NTMakefile @@ -0,0 +1,15 @@ +!INCLUDE + +CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsmt) + +CC_COMMON_OBJS = marshall.obj msg.obj generic_lists.obj + +CC_COMMON_LIB = cc_common.lib + +$(CC_COMMON_LIB): $(CC_COMMON_OBJS) + $(implib) /NOLOGO /OUT:$@ $** + +all: $(CC_COMMON_LIB) + +clean: + del *.obj *.lib diff --git a/src/lib/ccapi/common/generic_lists.c b/src/lib/ccapi/common/generic_lists.c new file mode 100644 index 0000000000..2c7398313d --- /dev/null +++ b/src/lib/ccapi/common/generic_lists.c @@ -0,0 +1,397 @@ +/* $Copyright: +* +* Copyright 2004-2006 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 MIT 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. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF +* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. +* +* Individual source code files are copyright MIT, Cygnus Support, +* OpenVision, Oracle, Sun Soft, FundsXpress, and others. +* +* Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, +* and Zephyr are trademarks of the Massachusetts Institute of Technology +* (MIT). No commercial use of these trademarks may be made without prior +* written permission of MIT. +* +* "Commercial use" means use of a name in a product or other for-profit +* manner. It does NOT prevent a commercial firm from referring to the MIT +* trademarks in order to convey information (although in doing so, +* recognition of their trademark status should be given). +* $ +*/ + + +/* + * Lists implementation. + * + */ + +#include +#include +#include + +#include "CredentialsCache.h" +#include "generic_lists.h" + +/** + * cci_generic_iterate_has_next() + * + * Purpose: Determine if an iterator has a next element + * + * Return: 1 if another element exists + * 0 if no additional elements exist + * + * Errors: None + * + */ +cc_int32 +cci_generic_iterate_has_next(cc_generic_iterate_t *iterate) +{ + return ((iterate == NULL || iterate->next == NULL) ? 0 : 1); +} + +/** + * cci_generic_iterate_next() + * + * Purpose: Retrieve the next element from an iterator and advance + * the iterator + * + * Return: non-NULL, the next element in the iterator + * NULL, the iterator list is empty or iterator is invalid + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_generic_iterate_next(cc_generic_iterate_t *iterator, cc_generic_list_node_t** nodepp) +{ + cc_generic_list_node_t* ret; + + if (iterator == NULL || nodepp == NULL) + return ccErrBadParam; + + ret = iterator->next; + if (iterator->next != NULL) + iterator->next = iterator->next->next; + + *nodepp = ret; + return ccNoError; +} + +/** + * cci_generic_list_new() + * + * Purpose: Allocate new generic list + * + * Return: non-NULL, an empty list + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +cci_generic_list_new(cc_generic_list_head_t ** listpp) +{ + cc_generic_list_head_t* ret = (cc_generic_list_head_t *)malloc(sizeof(cc_generic_list_head_t)); + if (ret == NULL) + return ccErrNoMem; + + ret->type = generic; + ret->head = ret->tail = NULL; + *listpp = ret; + + return ccNoError; +} + +/** + * cci_generic_list_append() + * + * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +cci_generic_list_append(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t** nodepp) +{ + cc_generic_list_node_t* new_node; + + if ( data == NULL || len == 0 ) + return ccErrBadParam; + + new_node = (cc_generic_list_node_t *)malloc(sizeof(cc_generic_list_node_t)); + if (new_node == NULL) + return ccErrNoMem; + + new_node->data = malloc(len); + if ( new_node->data == NULL ) { + free(new_node); + return ccErrNoMem; + } + + memcpy(new_node->data,data,len); + new_node->len = len; + + if (head->head == NULL) { /*empty list*/ + head->head = new_node; + head->tail = new_node; + new_node->next = new_node->prev = NULL; + } else { + new_node->prev = head->tail; + head->tail->next = new_node; + head->tail = new_node; + new_node->next = NULL; + } + if (nodepp != NULL) + *nodepp = new_node; + return ccNoError; +} + +/** + * cci_generic_list_prepend() + * + * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem, ccErrBadParam + * + */ +cc_int32 +cci_generic_list_prepend(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t** nodepp) +{ + cc_generic_list_node_t* new_node; + + if ( data == NULL || len == 0 ) + return ccErrBadParam; + + new_node = (cc_generic_list_node_t *)malloc(sizeof(cc_generic_list_node_t)); + if (new_node == NULL) + return ccErrNoMem; + + new_node->data = malloc(len); + if ( new_node->data == NULL ) { + free(new_node); + return ccErrNoMem; + } + + memcpy(new_node->data,data,len); + new_node->len = len; + + if (head->head == NULL) { /*empty list*/ + head->head = new_node; + head->tail = new_node; + new_node->prev = new_node->next = NULL; + } else { + new_node->next = head->head; + head->head->prev = new_node; + new_node->prev = NULL; + head->head = new_node; + } + + if (nodepp != NULL) + *nodepp = new_node; + + return ccNoError; +} + +/** + * cci_generic_list_remove_element() + * + * Purpose: Remove a node from the list + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_generic_list_remove_element(cc_generic_list_head_t* head, cc_generic_list_node_t* rem) +{ + if (head->head == NULL || rem == NULL) + return ccErrBadParam; + + if (head->head == rem && head->tail == rem) { /*removing only element of list*/ + head->head = head->tail = NULL; + } else if (head->head == rem) { /*removing head*/ + head->head = head->head->next; + } else if (head->tail == rem) { /*removing tail*/ + head->tail = head->tail->prev; + head->tail->next = NULL; + } else { + rem->prev->next = rem->next; + rem->next->prev = rem->prev; + } + free(rem); + return ccNoError; +} + +/** + * cci_generic_free_element() + * + * Purpose: Free the memory associated with a node + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_generic_free_element(cc_generic_list_node_t* node) +{ + if ( node == NULL ) + return ccErrBadParam; + + if ( node->data ) { + free(node->data); + node->data = NULL; + } + node->len = 0; + node->next = node->prev = NULL; + free(node); + return ccNoError; +} + + +/** + * cci_generic_list_destroy() + * + * Purpose: Deallocate a list and all of its contents + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + */ +cc_int32 +cci_generic_list_destroy(cc_generic_list_head_t* head) +{ + cc_generic_list_node_t *cur, *next; + cc_int32 ret = ccNoError; + + if ( head == NULL ) + return ccErrBadParam; + + for (cur = head->head; ret == ccNoError && cur != NULL; cur = next) { + next = cur->next; + ret = cci_generic_free_element(cur); + } + free(head); + return(ret); +} + +/** + * cci_generic_list_copy() + * + * Purpose: Copy a list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrBadParam, ccErrNoMem + * + */ +cc_int32 +cci_generic_list_copy(cc_generic_list_head_t* head, cc_generic_list_head_t** headpp) +{ + cc_generic_list_head_t* copy; + cc_generic_list_node_t *src_node, *dst_node; + cc_int32 code; + + if (head == NULL || headpp == NULL) + return ccErrBadParam; + + code = cci_generic_list_new(©); + if (code != ccNoError) + return code; + + for (src_node = head->head; src_node != NULL; src_node = src_node->next) { + code = cci_generic_list_append(copy, src_node->data, src_node->len, &dst_node); + if (code != ccNoError) { + cci_generic_list_destroy(copy); + return code; + } + } + *headpp = copy; + return ccNoError; +} + +/** + * cci_generic_list_iterator() + * + * Purpose: Allocate an iterator for the specified list + * + * Return: non-NULL, an iterator + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +cci_generic_list_iterator(cc_generic_list_head_t *head, cc_generic_iterate_t** headpp) +{ + cc_generic_iterate_t* iterator; + + if ( head == NULL || headpp == NULL ) + return ccErrBadParam; + + iterator = (cc_generic_iterate_t*)malloc(sizeof(cc_generic_iterate_t)); + if (iterator == NULL) + return ccErrNoMem; + + iterator->next = head->head; + *headpp = iterator; + return ccNoError; +} + +/** + * cci_generic_free_iterator() + * + * Purpose: Deallocate memory associated with an iterator + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_generic_free_iterator(cc_generic_iterate_t* iterator) +{ + if ( iterator == NULL ) + return ccErrBadParam; + + iterator->next = NULL; + free(iterator); + return ccNoError; +} + + + diff --git a/src/lib/ccapi/common/mac/mig.defs b/src/lib/ccapi/common/mac/mig.defs new file mode 100755 index 0000000000..dd3ee1b513 --- /dev/null +++ b/src/lib/ccapi/common/mac/mig.defs @@ -0,0 +1,58 @@ +/* $Copyright: + * + * Copyright 2004-2006 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 MIT 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. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Individual source code files are copyright MIT, Cygnus Support, + * OpenVision, Oracle, Sun Soft, FundsXpress, and others. + * + * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, + * and Zephyr are trademarks of the Massachusetts Institute of Technology + * (MIT). No commercial use of these trademarks may be made without prior + * written permission of MIT. + * + * "Commercial use" means use of a name in a product or other for-profit + * manner. It does NOT prevent a commercial firm from referring to the MIT + * trademarks in order to convey information (although in doing so, + * recognition of their trademark status should be given). + * $ + */ + +import "mig_types.h"; + +#include +#include + +subsystem ccapi 128; + +type msg_request_t = array [] of char; +type msg_reply_t = array [] of char; +type msg_error_t = int32; + +routine ccapi_msg (in_server_port : mach_port_t; + in_request : msg_request_t; + out out_reply : msg_reply_t; + out out_error : msg_error_t); diff --git a/src/lib/ccapi/common/mac/mig_types.h b/src/lib/ccapi/common/mac/mig_types.h new file mode 100644 index 0000000000..586a01994f --- /dev/null +++ b/src/lib/ccapi/common/mac/mig_types.h @@ -0,0 +1,48 @@ +/* $Copyright: +* +* Copyright 2004-2006 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 MIT 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. +* +* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED +* WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF +* MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. +* +* Individual source code files are copyright MIT, Cygnus Support, +* OpenVision, Oracle, Sun Soft, FundsXpress, and others. +* +* Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, +* and Zephyr are trademarks of the Massachusetts Institute of Technology +* (MIT). No commercial use of these trademarks may be made without prior +* written permission of MIT. +* +* "Commercial use" means use of a name in a product or other for-profit +* manner. It does NOT prevent a commercial firm from referring to the MIT +* trademarks in order to convey information (although in doing so, +* recognition of their trademark status should be given). +* $ +*/ + +#include "CredentialsCache.h" + +typedef const char *msg_request_t; +typedef char *msg_reply_t; +typedef cc_int32 msg_error_t; diff --git a/src/lib/ccapi/common/marshall.c b/src/lib/ccapi/common/marshall.c new file mode 100644 index 0000000000..48abb33702 --- /dev/null +++ b/src/lib/ccapi/common/marshall.c @@ -0,0 +1,441 @@ +/* $Copyright: + * + * Copyright 2004-2006 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 MIT 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. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Individual source code files are copyright MIT, Cygnus Support, + * OpenVision, Oracle, Sun Soft, FundsXpress, and others. + * + * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, + * and Zephyr are trademarks of the Massachusetts Institute of Technology + * (MIT). No commercial use of these trademarks may be made without prior + * written permission of MIT. + * + * "Commercial use" means use of a name in a product or other for-profit + * manner. It does NOT prevent a commercial firm from referring to the MIT + * trademarks in order to convey information (although in doing so, + * recognition of their trademark status should be given). + * $ + */ + +/* marshall.c */ + +#include +#include +#include +#include +#include "msg.h" +#include "msg_headers.h" +#include "marshall.h" + +cc_int32 +cci_creds_v4_marshall( cc_credentials_v4_t * creds, + char ** pflat, + cc_uint32 * plen) +{ + cc_uint32 len; + char * flat; + cci_flat_creds_v4_t * header; + cc_time64 t64; + + if ( creds == NULL || pflat == NULL || plen == NULL ) + return ccErrBadParam; + + len = sizeof(cci_flat_creds_v4_t); + flat = (char *)malloc(len); + if ( flat == NULL ) + return ccErrNoMem; + memset(flat, 0, len); + + header = (cci_flat_creds_v4_t *)flat; + header->version = htonl(creds->version); + memcpy(header->principal, creds->principal, cc_v4_name_size); + memcpy(header->principal_instance, creds->principal_instance, cc_v4_instance_size); + memcpy(header->service, creds->service, cc_v4_name_size); + memcpy(header->service_instance, creds->service_instance, cc_v4_instance_size); + memcpy(header->realm, creds->realm, cc_v4_realm_size); + memcpy(header->session_key, creds->session_key, cc_v4_key_size); + header->kvno = htonl(creds->kvno); + header->string_to_key_type = htonl(creds->string_to_key_type); + t64 = creds->issue_date; + header->issue_date = htonll(t64); + header->lifetime = htonl(creds->lifetime); + /* TODO: verify that address is stored in host order */ + header->address = htonl(creds->address); + header->ticket_size = htonl(creds->ticket_size); + memcpy(header->ticket, creds->ticket, cc_v4_ticket_size); + + *pflat = flat; + *plen = len; + + return ccNoError; +} + +cc_int32 +cci_creds_v4_unmarshall( char * flat, + cc_uint32 len, + cc_credentials_union * creds_union) +{ + struct cci_flat_creds_v4 * header; + cc_credentials_v4_t * creds; + cc_time64 t64; + + if ( flat == NULL || len == 0 || creds_union == NULL ) + return ccErrBadParam; + + creds_union->version = cc_credentials_v4; + + header = (cci_flat_creds_v4_t *)flat; + + creds = (cc_credentials_v4_t *)malloc(sizeof(cc_credentials_v4_t)); + if ( creds == NULL ) + return ccErrNoMem; + + creds->version = ntohl(header->version); + memcpy(creds->principal, header->principal, cc_v4_name_size); + memcpy(creds->principal_instance, header->principal_instance, cc_v4_instance_size); + memcpy(creds->service, header->service, cc_v4_name_size); + memcpy(creds->service_instance, header->service_instance, cc_v4_instance_size); + memcpy(creds->realm, header->realm, cc_v4_realm_size); + memcpy(creds->session_key, header->session_key, cc_v4_key_size); + creds->kvno = htonl(header->kvno); + creds->string_to_key_type = htonl(header->string_to_key_type); + t64 = header->issue_date; + creds->issue_date = (cc_time64)ntohll(t64); + creds->lifetime = (cc_int32)ntohl(header->lifetime); + /* TODO: verify that address is stored in host order */ + creds->address = ntohl(header->address); + creds->ticket_size = ntohl(header->ticket_size); + memcpy(creds->ticket, header->ticket, cc_v4_ticket_size); + + creds_union->credentials.credentials_v4 = creds; + + return ccNoError; +} + + +cc_int32 +cci_creds_cc_data_array_count_entries( cc_data ** array, cc_uint32 * pcount) +{ + cc_uint32 count; + + if (array == NULL) { + *pcount = 0; + return ccNoError; + } + + for ( count=0; array[count] != NULL ; count++) ; + + *pcount = count; + return ccNoError; +} + +cc_int32 +cci_creds_v5_compute_flat_size( cc_credentials_v5_t * creds, cc_uint32 * plen) +{ + cc_uint32 len; + cc_uint32 i, count; + + len = sizeof(struct cci_flat_creds_v5); + + if (creds->client) + len += strlen(creds->client) + 1; + + if (creds->server) + len += strlen(creds->server) + 1; + + len += creds->keyblock.length; + + cci_creds_cc_data_array_count_entries( creds->addresses, &count ); + len += count * sizeof(cc_flat_data); + for ( i=0; iaddresses[i]->length; + } + + len += creds->ticket.length; + len += creds->second_ticket.length; + + cci_creds_cc_data_array_count_entries( creds->authdata, &count ); + len += count * sizeof(cc_flat_data); + for ( i=0; iauthdata[i]->length; + } + + *plen = len; + return ccNoError; +} + +cc_int32 +cci_creds_v5_marshall( cc_credentials_v5_t * creds, + char ** pflat, + cc_uint32 * plen) +{ + cc_uint32 len; + char * flat; + struct cci_flat_creds_v5 * header; + cc_uint32 length; + cc_uint32 offset; + cc_time64 t64; + cc_uint32 count; + cc_uint32 i; + + if ( creds == NULL || pflat == NULL || plen == NULL ) + return ccErrBadParam; + + cci_creds_v5_compute_flat_size(creds, &len); + + flat = (char *)malloc(len); + if ( flat == NULL ) + return ccErrNoMem; + memset(flat, 0, len); + + offset = sizeof(struct cci_flat_creds_v5); + header = (struct cci_flat_creds_v5 *)flat; + header->version = htonl(FLAT_CREDS_V5_VERSION); + if (creds->client) { + length = strlen(creds->client) + 1; + header->client.length = htonl(length); + header->client.data = htonl(offset); + memcpy(flat + offset, creds->client, length); + offset += length; + } + + if (creds->server) { + length = strlen(creds->server) + 1; + header->server.length = htonl(length); + header->server.data = htonl(offset); + memcpy(flat + offset, creds->server, length); + offset += length; + } + + header->keyblock.type = htonl(creds->keyblock.type); + if (creds->keyblock.length) { + length = creds->keyblock.length; + header->keyblock.length = htonl(length); + header->keyblock.data = htonl(offset); + memcpy(flat + offset, creds->keyblock.data, length); + offset += length; + } + + t64 = creds->authtime; + header->authtime = htonll(t64); + t64 = creds->starttime; + header->starttime = htonll(t64); + t64 = creds->endtime; + header->endtime = htonll(t64); + t64 = creds->renew_till; + header->renew_till = htonll(t64); + + header->is_skey = htonl(creds->is_skey); + header->ticket_flags = htonl(creds->ticket_flags); + + cci_creds_cc_data_array_count_entries( creds->addresses, &count ); + if ( count ) { + cc_flat_data * addresses = (cc_flat_data *)flat + offset; + header->address_count = htonl(count); + header->addresses = htonl(offset); + offset += count * sizeof(cc_flat_data); + + for ( i=0; i < count; i++ ) { + addresses[i].type = htonl(creds->addresses[i]->type); + if (creds->addresses[i]->length) { + length = creds->addresses[i]->length; + addresses[i].length = htonl(length); + addresses[i].data = htonl(offset); + /* TODO: verify that addresses are stored in network order */ + memcpy(flat + offset, creds->addresses[i]->data, length); + offset += length; + } + } + } + + header->ticket.type = htonl(creds->ticket.type); + if (creds->ticket.length) { + length = creds->ticket.length; + header->ticket.length = htonl(length); + header->ticket.data = htonl(offset); + memcpy(flat + offset, creds->ticket.data, length); + offset += length; + } + + header->second_ticket.type = htonl(creds->second_ticket.type); + if (creds->second_ticket.length) { + length = creds->second_ticket.length; + header->second_ticket.length = htonl(length); + header->second_ticket.data = htonl(offset); + memcpy(flat + offset, creds->second_ticket.data, length); + offset += length; + } + + cci_creds_cc_data_array_count_entries( creds->authdata, &count ); + if ( count ) { + cc_flat_data * authdata = (cc_flat_data *)flat + offset; + + header->authdata_count = htonl(count); + header->authdata = (offset); + offset += count * sizeof(cc_flat_data); + + for ( i=0; i < count; i++ ) { + authdata[i].type = htonl(creds->authdata[i]->type); + if (creds->authdata[i]->length) { + length = creds->authdata[i]->length; + authdata[i].length = htonl(length); + authdata[i].data = htonl(offset); + memcpy(flat + offset, creds->authdata[i]->data, length); + offset += length; + } + } + } + + *pflat = flat; + *plen = len; + return ccNoError; +} + + +// TODO: a much better job of checking for out of memory errors +// and validating that we do not read beyond the flat input +// data buffer + +cc_int32 +cci_creds_v5_unmarshall( char * flat, + cc_uint32 len, + cc_credentials_union * creds_union) +{ + struct cci_flat_creds_v5 * header; + cc_credentials_v5_t * creds; + cc_flat_data * flat_data; + cc_time64 t64; + cc_uint32 length; + cc_uint32 count; + cc_uint32 i; + + if ( flat == NULL || len == 0 || creds_union == NULL ) + return ccErrBadParam; + + creds_union->version = cc_credentials_v5; + + header = (struct cci_flat_creds_v5 *)flat; + + if ( ntohl(header->version) != FLAT_CREDS_V5_VERSION ) + return ccErrBadParam; + + creds = (cc_credentials_v5_t *)malloc(sizeof(cc_credentials_v5_t)); + if ( creds == NULL ) + return ccErrNoMem; + memset(creds, 0, sizeof(cc_credentials_v5_t)); + + if ( header->client.length ) { + length = ntohl(header->client.length); + creds->client = (char *)malloc(length); + memcpy(creds->client, flat + header->client.data, length); + } + + if ( header->server.length ) { + length = ntohl(header->server.length); + creds->server = (char *)malloc(length); + memcpy(creds->server, flat + header->server.data, length); + } + + creds->keyblock.type = ntohl(header->keyblock.type); + if ( header->keyblock.length ) { + length = ntohl(header->keyblock.length); + creds->keyblock.length = length; + creds->keyblock.data = malloc(length); + memcpy(creds->keyblock.data, flat + header->keyblock.data, length); + } + + /* TODO: need to perform overflow validation checks to ensure + * that we do not attempt to store too large a value into cc_time_t + * when it is a 32-bit field. + */ + t64 = ntohll(header->authtime); + creds->authtime = (cc_time)t64; + t64 = ntohll(header->starttime); + creds->starttime = (cc_time)t64; + t64 = ntohll(header->endtime); + creds->endtime = (cc_time)t64; + t64 = ntohll(header->renew_till); + creds->renew_till = (cc_time)t64; + + creds->is_skey = ntohl(header->is_skey); + creds->ticket_flags = ntohl(header->ticket_flags); + + count = ntohl(header->address_count); + creds->addresses = (cc_data **) malloc((count + 1) * sizeof(cc_data *)); + flat_data = (cc_flat_data *)flat + header->addresses; + for ( i=0 ; i < count ; i++ ) { + creds->addresses[i] = (cc_data *)malloc(sizeof(cc_data)); + creds->addresses[i]->type = ntohl(flat_data[i].type); + length = ntohl(flat_data[i].length); + creds->addresses[i]->length = length; + if ( length ) { + creds->addresses[i]->data = malloc(length); + /* TODO: verify that addresses are stored in network order */ + memcpy(creds->addresses[i]->data, flat + flat_data[i].data, length); + } else { + creds->addresses[i]->data = NULL; + } + } + creds->addresses[i] = NULL; + + creds->ticket.type = ntohl(header->ticket.type); + length = ntohl(header->ticket.length); + if ( length ) { + creds->ticket.length = length; + creds->ticket.data = malloc(length); + memcpy(creds->ticket.data, flat + header->ticket.data, length); + } + + creds->second_ticket.type = header->second_ticket.type; + if ( header->second_ticket.length ) { + creds->second_ticket.length = header->second_ticket.length; + creds->second_ticket.data = malloc(creds->second_ticket.length); + memcpy(creds->second_ticket.data, flat + header->second_ticket.data, creds->second_ticket.length); + } + + count = ntohl(header->authdata_count); + creds->authdata = (cc_data **) malloc((count + 1) * sizeof(cc_data *)); + flat_data = (cc_flat_data *)flat + header->authdata; + for ( i=0 ; i < count ; i++ ) { + creds->authdata[i] = (cc_data *)malloc(sizeof(cc_data)); + creds->authdata[i]->type = ntohl(flat_data[i].type); + length = ntohl(flat_data[i].length); + creds->authdata[i]->length = length; + if ( length ) { + creds->authdata[i]->data = malloc(length); + memcpy(creds->authdata[i]->data, flat + flat_data[i].data, length); + } else { + creds->authdata[i]->data = NULL; + } + } + creds->authdata[i] = NULL; + + creds_union->credentials.credentials_v5 = creds; + + return ccNoError; +} + diff --git a/src/lib/ccapi/msg.c b/src/lib/ccapi/common/msg.c similarity index 79% rename from src/lib/ccapi/msg.c rename to src/lib/ccapi/common/msg.c index f5f074aa04..789fc87464 100644 --- a/src/lib/ccapi/msg.c +++ b/src/lib/ccapi/common/msg.c @@ -1,582 +1,622 @@ -/* $Copyright: - * - * Copyright 2004 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 MIT 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. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* - * Verifiable, extensible message format. - */ - -#include "CredentialsCache.h" -#include "msg.h" -#include "datastore.h" - -#include -#include -#include -#include - -/** - * cci_msg_new() - * - * Purpose: Allocate and initialize a new cc_msg_t structure - * - * Return: non-NULL, the msg - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_msg_new(cc_uint32 type, cc_msg_t** msgpp) -{ - // type should be validated. If invalid set error to ccErrBadParam - cc_msg_t* msg; - - if ( type > CC_MSG_MAX_TYPE || msgpp == NULL ) - return ccErrBadParam; - - msg = (cc_msg_t*)malloc(sizeof(cc_msg_t)); - if (msg == NULL) - return ccErrNoMem; - - msg->type = type; - msg->flat = NULL; - msg->header = NULL; - msg->flat_len = 0; - msg->header_len = 0; - msg->magic = 0; - cci_generic_list_new(&msg->data_blobs); - if (msg->data_blobs == NULL) { - // pass on error from previous call - free(msg); - return ccErrNoMem; - } - - *msgpp = msg; - return ccNoError; -} - -/** - * cci_msg_calc_header_size() - * - * Purpose: Calculates the size of the header - * - * Return: the size in bytes - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_msg_calc_header_size(cc_msg_t* msg, cc_uint32 * lenp) -{ - int header_len = 12; /* header size, entire size, type */ - - if ( msg == NULL || lenp == NULL ) - return ccErrBadParam; - - header_len += msg->header_len; - *lenp = header_len; - return ccNoError; -} - -/** - * cci_msg_calc_size() - * - * Purpose: Calculates the size of the message - * (does not include the magic bytes) - * - * Return: the size in bytes - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_msg_calc_size(cc_msg_t* msg, cc_uint32 * lenp) -{ - cc_uint32 flat_len; - cc_generic_list_node_t* gen_node; - cc_generic_iterate_t* gen_iterator; - cc_int32 code; - - if ( msg == NULL || lenp == NULL ) - return ccErrBadParam; - - code = cci_msg_calc_header_size(msg, &flat_len); - if (code != ccNoError) - goto bad; - - code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); - if ( code != ccNoError ) - goto bad; - - while (cci_generic_iterate_has_next(gen_iterator)) { - code = cci_generic_iterate_next(gen_iterator, &gen_node); - if (code != ccNoError) - break; - flat_len += gen_node->len + BLOB_LEN; - } - cci_generic_free_iterator(gen_iterator); - if (code != ccNoError) - goto bad; - - flat_len += MAGIC_HEAD_LEN + MAGIC_DATA_LEN; - *lenp = flat_len; - - bad: - return code; -} - -/** - * cci_msg_add_data_blob() - * - * Purpose: Adds 'len' bytes of data to the msg - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_add_data_blob(cc_msg_t* msg, void *data, cc_uint32 len, cc_uint32 *lenp) -{ - cc_int32 code; - - if (msg == NULL || data == NULL || len <= 0 || lenp == NULL) - return ccErrBadParam; - - code = cci_generic_list_append(msg->data_blobs, data, len, NULL); - if ( code != ccNoError ) - return code; - return cci_msg_calc_blob_pos(msg, data, len, lenp); -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_calc_blob_pos(cc_msg_t* msg, void *data, cc_uint32 len, cc_uint32 * posp) -{ - cc_uint32 pos; - cc_generic_list_node_t* gen_node; - cc_generic_iterate_t* gen_iterator; - cc_int32 code; - - code = cci_msg_calc_header_size(msg, &pos); - pos += sizeof(cc_uint32); /*+ sizeof(cc_uint32) for magic*/ - - code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); - while (cci_generic_iterate_has_next(gen_iterator)) { - code = cci_generic_iterate_next(gen_iterator, &gen_node); - if (gen_node->len != len && gen_node->data != data) { - pos += gen_node->len + sizeof(cc_uint32); - } else { - cci_generic_free_iterator(gen_iterator); - *posp = pos + sizeof(cc_uint32); - return ccNoError; - } - } - - cci_generic_free_iterator(gen_iterator); - return ccIteratorEnd; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_add_header(cc_msg_t* msg, void *header, cc_uint32 header_len) -{ - if ( msg == NULL || header == NULL ) - return ccErrBadParam; - - msg->header = header; - msg->header_len = header_len; - return ccNoError; -} - - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_flatten(cc_msg_t* msg, void **flatpp) -{ - cc_generic_list_node_t* gen_node; - cc_generic_iterate_t* gen_iterator; - char *cur_pos; - cc_uint32 zero = 0; - cc_uint32 magic = 0; - cc_uint32 msg_len; - cc_int32 code; - - if (msg == NULL || flatpp == NULL) - return ccErrBadParam; - - code = cci_msg_calc_size(msg,&msg->flat_len); - if ( code != ccNoError ) - return code; - - if (msg->flat_len > CC_MSG_MAX_SIZE) - return ccErrBadParam; - - msg->flat = (void *)malloc(msg->flat_len); - if (msg->flat == NULL) - return ccErrNoMem; - - cur_pos = msg->flat; - - memcpy(cur_pos,&msg->header_len,sizeof(cc_uint32)); - cur_pos+=sizeof(cc_uint32); - - memcpy(cur_pos,&msg->flat_len,sizeof(cc_uint32)); - cur_pos+=sizeof(cc_uint32); - - memcpy(cur_pos,&msg->type,sizeof(cc_uint32)); - cur_pos+=sizeof(cc_uint32); - - memcpy(cur_pos, msg->header, msg->header_len); - cur_pos += msg->header_len; - - memcpy(cur_pos, &zero, sizeof(cc_uint32)); /*will be magic number later*/ - cur_pos += sizeof(cc_uint32); - - code = cci_generic_list_iterator(msg->data_blobs,&gen_iterator); - if ( code != ccNoError ) { - free(msg->flat); - return code; - } - - while (cci_generic_iterate_has_next(gen_iterator)) { - code = cci_generic_iterate_next(gen_iterator, &gen_node); - if (code != ccNoError) { - free(gen_iterator); - free(msg->flat); - return code; - } - memcpy(cur_pos, &gen_node->len, sizeof(cc_uint32)); - cur_pos+=sizeof(cc_uint32); - - memcpy(cur_pos, gen_node->data, gen_node->len); - cur_pos += gen_node->len; - } - free(gen_iterator); - - memcpy(cur_pos, &zero, sizeof(cc_uint32)); /*magic number will go here later*/ - cur_pos += sizeof(cc_uint32); - - if (cur_pos - (char *)msg->flat != msg->flat_len) { - printf("ERRORR cur_pos - msg->flat = %d\n",msg->flat_len); - } - - cci_msg_calc_magic(msg->flat, msg->flat_len, &magic); - printf("magic = %d\n",magic); - - cci_msg_calc_header_size(msg, &msg_len); - memcpy((char *)msg->flat + msg_len, &magic, sizeof(cc_uint32)); - memcpy((char *)msg->flat + msg->flat_len - sizeof(cc_uint32), &magic, sizeof(cc_uint32)); - - if ( flatpp != NULL ) - *flatpp = msg->flat; - return ccNoError; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_calc_magic(void *flat, int flat_len, cc_uint32 * magicp) -{ - cc_uint32 magic = 0; - int i; - - for (i = 0; i < flat_len; i += sizeof(cc_uint32)) { - magic = magic ^ *(int *)((char *)flat + i); - } - *magicp = magic; - return ccNoError; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_verify(void *flat, int flat_len, cc_uint32 * validp) -{ - cc_uint32 *magic1, *magic2; - cc_uint32 *pheader_len; - cc_uint32 *ptotal_len; - cc_uint32 *pblob_len; - cc_uint32 *ptype; - cc_uint32 num_blobs = 0; - cc_uint32 zero = 0; - cc_uint32 msg_magic, msg_magic2; - - if (flat == NULL || flat_len <= 0 || validp == NULL) - return ccErrBadParam; - - pheader_len = flat; - ptotal_len = (cc_uint32 *)((char *)pheader_len + sizeof(cc_uint32)); - ptype = (cc_uint32 *)((char *)ptotal_len + sizeof(cc_uint32)); - - if (*ptotal_len != flat_len) { - *validp = 0; - return ccNoError; - } - - if (*pheader_len > flat_len) { - /*too weak. We could verify header_len against type spec header.*/ - *validp = 0; - return ccNoError; - } - if (*ptype > CC_MSG_MAX_TYPE) { - *validp = 0; - return ccNoError; - } - - magic1 = (cc_uint32 *)((char *)ptype + sizeof(cc_uint32) + *pheader_len); - if ((char *)magic1 - (char *)flat == (flat_len - 8)) { - /*There are no data blobs*/ - magic2 = (cc_uint32 *)((char *)magic1 + sizeof(cc_uint32)); - num_blobs = 0; - } else { - pblob_len = (cc_uint32 *)((char *)magic1 + sizeof(cc_uint32)); - num_blobs = 1; - - while (*pblob_len + sizeof(cc_uint32) + ((char *)pblob_len - (char *)flat) < (flat_len - sizeof(cc_uint32))) { - pblob_len = (cc_uint32 *)((char *)pblob_len + *pblob_len + sizeof(cc_uint32)); - num_blobs++; - } - - if (*pblob_len + sizeof(cc_uint32) + ((char *)pblob_len - (char *)flat) != (flat_len - sizeof(cc_uint32))) { - /*blobs didn't line up*/ - *validp = 0; - return ccNoError; - } - magic2 = (cc_uint32 *)((char *)pblob_len + *pblob_len + sizeof(cc_uint32)); /*2nd magic should be directly after the last blob*/ - } - - if (*magic1 != *magic2) { - *validp = 0; - return ccNoError; - } - msg_magic = *magic1; - - printf("%d %d\n", (char *)magic1 - (char *)flat, (char *)magic2 - (char *)flat); - - memcpy(magic1, &zero, sizeof(cc_uint32)); - memcpy(magic2, &zero, sizeof(cc_uint32)); - cci_msg_calc_magic(flat, flat_len, &msg_magic2); - if (msg_magic != msg_magic2) { - *validp = 0; - return ccNoError; - } - memcpy(magic1, &msg_magic, sizeof(cc_uint32)); - memcpy(magic2, &msg_magic, sizeof(cc_uint32)); - - *validp = 1; - return ccNoError; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_unflatten(void *flat, int flat_len, cc_msg_t** msgpp) -{ - cc_msg_t* msg; - char *cur_pos; - cc_uint32 blob_len; - char *blob; - cc_uint32 valid; - cc_int32 code; - - if ( flat == NULL || flat_len <= 0 || msgpp == NULL ) - return ccErrBadParam; - - code = cci_msg_new(0, &msg); - if (code) - return code; - - cci_msg_verify(flat, flat_len, &valid); - if (valid != 1) { - cci_msg_destroy(msg); - return ccErrBadParam; - } - - cur_pos = flat; - msg->flat = flat; - - msg->header_len = *(cc_uint32 *)cur_pos; - cur_pos += sizeof(cc_uint32); - - msg->flat_len = *(cc_uint32 *)cur_pos; - cur_pos += sizeof(cc_uint32); - - msg->type = *(cc_uint32 *)cur_pos; - cur_pos += sizeof(cc_uint32); - - msg->header = (void *)malloc(msg->header_len); - if (msg->header == NULL) { - cci_msg_destroy(msg); - return ccErrNoMem; - } - memcpy(msg->header, cur_pos, msg->header_len); - cur_pos += msg->header_len; - - msg->magic = *(cc_uint32 *)cur_pos; - cur_pos += sizeof(cc_uint32); - - if (cur_pos - (char *)flat != flat_len - 8) { /*at least 1 blob*/ - blob_len = *(cc_uint32 *)cur_pos; - while (blob_len + (cur_pos - (char *)flat) + sizeof(cc_uint32) <= flat_len - sizeof(cc_uint32)) { - blob = (void *)malloc(blob_len); - if (blob == NULL) { - cci_msg_destroy(msg); - return ccErrNoMem; - } - memcpy(blob, cur_pos + sizeof(cc_uint32), blob_len); - cci_generic_list_append(msg->data_blobs, blob, blob_len, NULL); - - cur_pos += sizeof(cc_uint32) + blob_len; - blob_len = *(int *)cur_pos; - } - } - *msgpp = msg; - return ccNoError; -} - -cc_int32 -cci_msg_retrieve_blob(cc_msg_t* msg, cc_uint32 blob_offset, cc_uint32 blob_len, void **blobp) -{ - cc_generic_iterate_t* gen_iterator; - cc_generic_list_node_t* gen_node; - void *ret; - cc_uint32 blob_pos; - cc_int32 code; - - /*Ensure that the message has been unflattened*/ - if ( msg == NULL || msg->flat == NULL || blob_offset > msg->flat_len || - blob_len > msg->flat_len - blob_offset || blobp == NULL) - return ccErrBadParam; - - code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); - while (cci_generic_iterate_has_next(gen_iterator)) { - code = cci_generic_iterate_next(gen_iterator, &gen_node); - code = cci_msg_calc_blob_pos(msg, gen_node->data, gen_node->len, &blob_pos); - if (blob_pos == blob_offset && gen_node->len == blob_len) { - free(gen_iterator); - ret = (void *)malloc(blob_len); - if (ret == NULL) - return ccErrNoMem; - memcpy(ret,(char *)msg->flat + blob_offset, blob_len); - *blobp = ret; - return ccNoError; - } - } - free(gen_iterator); - return ccIteratorEnd; -} - -/** - * cc_msg_ - * - * Purpose: - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_msg_destroy(cc_msg_t* msg) -{ - if (msg->flat != NULL) - free(msg->flat); - if (msg->header != NULL) - free(msg->flat); - cci_generic_list_destroy(msg->data_blobs); - free(msg); - return ccNoError; -} - +/* $Copyright: + * + * Copyright 2004-2006 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 MIT 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. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Individual source code files are copyright MIT, Cygnus Support, + * OpenVision, Oracle, Sun Soft, FundsXpress, and others. + * + * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, + * and Zephyr are trademarks of the Massachusetts Institute of Technology + * (MIT). No commercial use of these trademarks may be made without prior + * written permission of MIT. + * + * "Commercial use" means use of a name in a product or other for-profit + * manner. It does NOT prevent a commercial firm from referring to the MIT + * trademarks in order to convey information (although in doing so, + * recognition of their trademark status should be given). + * $ + */ + +/* + * Verifiable, extensible message format. + * + * Format: + * + * + * + * + * + * + * + * + * + * ... + * + * + * If the header has variable length data it is included in the data blobs. + * The header field has the offset from the beginning of the message of the 1st + * byte of the data and the length of the data. + */ + +#include "CredentialsCache.h" +#include "msg.h" +#include "generic_lists.h" + +#include +#include +#include +#include + +/** + * cci_msg_new() + * + * Purpose: Allocate and initialize a new cc_msg_t structure + * + * Input parameter (type) in host order + * + * Return: non-NULL, the msg + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +cci_msg_new(cc_uint32 type, cc_msg_t** msgpp) +{ + // type should be validated. If invalid set error to ccErrBadParam + cc_msg_t* msg; + + if ( type > CC_MSG_MAX_TYPE || msgpp == NULL ) + return ccErrBadParam; + + msg = (cc_msg_t*)malloc(sizeof(cc_msg_t)); + if (msg == NULL) + return ccErrNoMem; + + msg->type = type; + msg->flat = NULL; + msg->header = NULL; + msg->flat_len = 0; + msg->header_len = 0; + msg->magic = 0; + cci_generic_list_new(&msg->data_blobs); + if (msg->data_blobs == NULL) { + // pass on error from previous call + free(msg); + return ccErrNoMem; + } + + *msgpp = msg; + return ccNoError; +} + +/** + * cci_msg_calc_header_size() + * + * Purpose: Calculates the size of the header + * + * Return: the size in bytes + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_msg_calc_header_size(cc_msg_t* msg, cc_uint32 * lenp) +{ + int header_len = 12; /* header size, entire size, type */ + + if ( msg == NULL || lenp == NULL ) + return ccErrBadParam; + + header_len += msg->header_len; + *lenp = header_len; + return ccNoError; +} + +/** + * cci_msg_calc_size() + * + * Purpose: Calculates the size of the message + * (does not include the magic bytes) + * + * Return: the size in bytes + * + * Errors: ccErrBadParam + * + */ +cc_int32 +cci_msg_calc_size(cc_msg_t* msg, cc_uint32 * lenp) +{ + cc_uint32 flat_len; + cc_generic_list_node_t* gen_node; + cc_generic_iterate_t* gen_iterator; + cc_int32 code; + + if ( msg == NULL || lenp == NULL ) + return ccErrBadParam; + + code = cci_msg_calc_header_size(msg, &flat_len); + if (code != ccNoError) + goto bad; + + code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); + if ( code != ccNoError ) + goto bad; + + while (cci_generic_iterate_has_next(gen_iterator)) { + code = cci_generic_iterate_next(gen_iterator, &gen_node); + if (code != ccNoError) + break; + flat_len += gen_node->len + BLOB_LEN; + } + cci_generic_free_iterator(gen_iterator); + if (code != ccNoError) + goto bad; + + flat_len += MAGIC_HEAD_LEN + MAGIC_DATA_LEN; + *lenp = flat_len; + + bad: + return code; +} + +/** + * cci_msg_add_data_blob() + * + * Purpose: Adds 'len' bytes of data to the msg + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_add_data_blob(cc_msg_t* msg, void *data, cc_uint32 len, cc_uint32 *lenp) +{ + cc_int32 code; + + if (msg == NULL || data == NULL || len <= 0 || lenp == NULL) + return ccErrBadParam; + + code = cci_generic_list_append(msg->data_blobs, data, len, NULL); + if ( code != ccNoError ) + return code; + return cci_msg_calc_blob_pos(msg, data, len, lenp); +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_calc_blob_pos(cc_msg_t* msg, void *data, cc_uint32 len, cc_uint32 * posp) +{ + cc_uint32 pos; + cc_generic_list_node_t* gen_node; + cc_generic_iterate_t* gen_iterator; + cc_int32 code; + + code = cci_msg_calc_header_size(msg, &pos); + pos += sizeof(cc_uint32); /*+ sizeof(cc_uint32) for magic*/ + + code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); + while (cci_generic_iterate_has_next(gen_iterator)) { + code = cci_generic_iterate_next(gen_iterator, &gen_node); + if (gen_node->len != len && gen_node->data != data) { + pos += gen_node->len + sizeof(cc_uint32); + } else { + cci_generic_free_iterator(gen_iterator); + *posp = pos + sizeof(cc_uint32); + return ccNoError; + } + } + + cci_generic_free_iterator(gen_iterator); + return ccIteratorEnd; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_add_header(cc_msg_t* msg, void *header, cc_uint32 header_len) +{ + if ( msg == NULL || header == NULL ) + return ccErrBadParam; + + msg->header = header; + msg->header_len = header_len; + return ccNoError; +} + + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_flatten(cc_msg_t* msg, void **flatpp) +{ + cc_generic_list_node_t* gen_node; + cc_generic_iterate_t* gen_iterator; + char *cur_pos; + cc_uint32 zero = 0; + cc_uint32 magic = 0; + cc_uint32 msg_len; + cc_uint32 u32; + cc_int32 code; + + if (msg == NULL) + return ccErrBadParam; + + code = cci_msg_calc_size(msg,&msg->flat_len); + if ( code != ccNoError ) + return code; + + if (msg->flat_len > CC_MSG_MAX_SIZE) + return ccErrBadParam; + + msg->flat = (void *)malloc(msg->flat_len); + if (msg->flat == NULL) + return ccErrNoMem; + + cur_pos = msg->flat; + + u32 = htonl(msg->header_len); + memcpy(cur_pos,&u32,sizeof(cc_uint32)); + cur_pos+=sizeof(cc_uint32); + + u32 = htonl(msg->flat_len); + memcpy(cur_pos,&u32,sizeof(cc_uint32)); + cur_pos+=sizeof(cc_uint32); + + u32 = htonl(msg->type); + memcpy(cur_pos,&u32,sizeof(cc_uint32)); + cur_pos+=sizeof(cc_uint32); + + /* header data is already in network order */ + memcpy(cur_pos, msg->header, msg->header_len); + cur_pos += msg->header_len; + + u32 = htonl(zero); + memcpy(cur_pos, &u32, sizeof(cc_uint32)); /*will be magic number later*/ + cur_pos += sizeof(cc_uint32); + + code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); + if ( code != ccNoError ) { + free(msg->flat); + return code; + } + + while (cci_generic_iterate_has_next(gen_iterator)) { + code = cci_generic_iterate_next(gen_iterator, &gen_node); + if (code != ccNoError) { + free(gen_iterator); + free(msg->flat); + return code; + } + u32 = htonl(gen_node->len); + memcpy(cur_pos, &u32, sizeof(cc_uint32)); + cur_pos+=sizeof(cc_uint32); + + /* data already in network order */ + memcpy(cur_pos, gen_node->data, gen_node->len); + cur_pos += gen_node->len; + } + free(gen_iterator); + + u32 = htonl(zero); + memcpy(cur_pos, &u32, sizeof(cc_uint32)); /*magic number will go here later*/ + cur_pos += sizeof(cc_uint32); + + if (cur_pos - (char *)msg->flat != msg->flat_len) { + fprintf(stderr, "ERROR cur_pos - msg->flat = %d\n",msg->flat_len); + } + + cci_msg_calc_magic(msg->flat, msg->flat_len, &magic); + printf("magic = %d\n",magic); + + cci_msg_calc_header_size(msg, &msg_len); + memcpy((char *)msg->flat + msg_len, &magic, sizeof(cc_uint32)); + memcpy((char *)msg->flat + msg->flat_len - sizeof(cc_uint32), &magic, sizeof(cc_uint32)); + + if ( flatpp != NULL ) + *flatpp = msg->flat; + + return ccNoError; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_calc_magic(void *flat, int flat_len, cc_uint32 * magicp) +{ + cc_uint32 magic = 0; + int i; + + for (i = 0; i < flat_len; i += sizeof(cc_uint32)) { + magic = magic ^ *(int *)((char *)flat + i); + } + *magicp = htonl(magic); + return ccNoError; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_verify(void *flat, int flat_len, cc_uint32 * validp) +{ + cc_uint32 *magic1, *magic2; + cc_uint32 *pheader_len; + cc_uint32 header_len; + cc_uint32 *ptotal_len; + cc_uint32 total_len; + cc_uint32 *pblob_len; + cc_uint32 blob_len; + cc_uint32 *ptype; + cc_uint32 type; + cc_uint32 num_blobs = 0; + cc_uint32 zero = 0; + cc_uint32 msg_magic, msg_magic2; + + if (flat == NULL || flat_len <= 0 || validp == NULL) + return ccErrBadParam; + + pheader_len = flat; + ptotal_len = (cc_uint32 *)((char *)pheader_len + sizeof(cc_uint32)); + ptype = (cc_uint32 *)((char *)ptotal_len + sizeof(cc_uint32)); + + header_len = ntohl(*pheader_len); + total_len = ntohl(*ptotal_len); + type = ntohl(*ptype); + + if (total_len != flat_len) { + *validp = 0; + return ccNoError; + } + + if (header_len > flat_len) { + /*too weak. We could verify header_len against type spec header.*/ + *validp = 0; + return ccNoError; + } + if (type > CC_MSG_MAX_TYPE) { + *validp = 0; + return ccNoError; + } + + magic1 = (cc_uint32 *)((char *)ptype + sizeof(cc_uint32) + header_len); + if ((char *)magic1 - (char *)flat == (flat_len - 8)) { + /*There are no data blobs*/ + magic2 = (cc_uint32 *)((char *)magic1 + sizeof(cc_uint32)); + num_blobs = 0; + } else { + pblob_len = (cc_uint32 *)((char *)magic1 + sizeof(cc_uint32)); + num_blobs = 1; + blob_len = ntohl(*pblob_len); + + while (blob_len + sizeof(cc_uint32) + ((char *)pblob_len - (char *)flat) < (flat_len - sizeof(cc_uint32))) { + pblob_len = (cc_uint32 *)((char *)pblob_len + blob_len + sizeof(cc_uint32)); + num_blobs++; + blob_len = ntohl(*pblob_len); + } + + if (blob_len + sizeof(cc_uint32) + ((char *)pblob_len - (char *)flat) != (flat_len - sizeof(cc_uint32))) { + /*blobs didn't line up*/ + *validp = 0; + return ccNoError; + } + magic2 = (cc_uint32 *)((char *)pblob_len + blob_len + sizeof(cc_uint32)); /*2nd magic should be directly after the last blob*/ + } + + if (*magic1 != *magic2) { + *validp = 0; + return ccNoError; + } + msg_magic = *magic1; + + printf("%d %d\n", (char *)magic1 - (char *)flat, (char *)magic2 - (char *)flat); + + memcpy(magic1, &zero, sizeof(cc_uint32)); + memcpy(magic2, &zero, sizeof(cc_uint32)); + cci_msg_calc_magic(flat, flat_len, &msg_magic2); + /* both msg_magic and msg_magic2 are in network order */ + if (msg_magic != msg_magic2) { + *validp = 0; + return ccNoError; + } + memcpy(magic1, &msg_magic, sizeof(cc_uint32)); + memcpy(magic2, &msg_magic, sizeof(cc_uint32)); + + *validp = 1; + return ccNoError; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_unflatten(void *flat, int flat_len, cc_msg_t** msgpp) +{ + cc_msg_t* msg; + char *cur_pos; + cc_uint32 blob_len; + char *blob; + cc_uint32 valid; + cc_int32 code; + + if ( flat == NULL || flat_len <= 0 || msgpp == NULL ) + return ccErrBadParam; + + code = cci_msg_new(0, &msg); + if (code) + return code; + + cci_msg_verify(flat, flat_len, &valid); + if (valid != 1) { + cci_msg_destroy(msg); + return ccErrBadParam; + } + + cur_pos = flat; + msg->flat = flat; + + msg->header_len = ntohl(*(cc_uint32 *)cur_pos); + cur_pos += sizeof(cc_uint32); + + msg->flat_len = ntohl(*(cc_uint32 *)cur_pos); + cur_pos += sizeof(cc_uint32); + + msg->type = ntohl(*(cc_uint32 *)cur_pos); + cur_pos += sizeof(cc_uint32); + + msg->header = (void *)malloc(msg->header_len); + if (msg->header == NULL) { + cci_msg_destroy(msg); + return ccErrNoMem; + } + memcpy(msg->header, cur_pos, msg->header_len); + cur_pos += msg->header_len; + + msg->magic = ntohl(*(cc_uint32 *)cur_pos); + cur_pos += sizeof(cc_uint32); + + if (cur_pos - (char *)flat != flat_len - 8) { /*at least 1 blob*/ + blob_len = ntohl(*(cc_uint32 *)cur_pos); + while (blob_len + (cur_pos - (char *)flat) + sizeof(cc_uint32) <= flat_len - sizeof(cc_uint32)) { + blob = (void *)malloc(blob_len); + if (blob == NULL) { + cci_msg_destroy(msg); + return ccErrNoMem; + } + memcpy(blob, cur_pos + sizeof(cc_uint32), blob_len); + cci_generic_list_append(msg->data_blobs, blob, blob_len, NULL); + + cur_pos += sizeof(cc_uint32) + blob_len; + blob_len = ntohl(*(int *)cur_pos); + } + } + *msgpp = msg; + return ccNoError; +} + +cc_int32 +cci_msg_retrieve_blob(cc_msg_t* msg, cc_uint32 blob_offset, cc_uint32 blob_len, char **blobp) +{ + cc_generic_iterate_t* gen_iterator; + cc_generic_list_node_t* gen_node; + void *ret; + cc_uint32 blob_pos; + cc_int32 code; + + /*Ensure that the message has been unflattened*/ + if ( msg == NULL || msg->flat == NULL || blob_offset > msg->flat_len || + blob_len > msg->flat_len - blob_offset || blobp == NULL) + return ccErrBadParam; + + code = cci_generic_list_iterator(msg->data_blobs, &gen_iterator); + while (cci_generic_iterate_has_next(gen_iterator)) { + code = cci_generic_iterate_next(gen_iterator, &gen_node); + code = cci_msg_calc_blob_pos(msg, gen_node->data, gen_node->len, &blob_pos); + if (blob_pos == blob_offset && gen_node->len == blob_len) { + free(gen_iterator); + ret = (void *)malloc(blob_len); + if (ret == NULL) + return ccErrNoMem; + memcpy(ret,(char *)msg->flat + blob_offset, blob_len); + *blobp = ret; + return ccNoError; + } + } + free(gen_iterator); + return ccIteratorEnd; +} + +/** + * cc_msg_ + * + * Purpose: + * + * Return: + * + * Errors: + * + */ +cc_int32 +cci_msg_destroy(cc_msg_t* msg) +{ + if (msg->flat != NULL) + free(msg->flat); + if (msg->header != NULL) + free(msg->header); + cci_generic_list_destroy(msg->data_blobs); + free(msg); + return ccNoError; +} + diff --git a/src/lib/ccapi/doc/implementation-notes.txt b/src/lib/ccapi/doc/implementation-notes.txt new file mode 100644 index 0000000000..e6150fb23e --- /dev/null +++ b/src/lib/ccapi/doc/implementation-notes.txt @@ -0,0 +1,156 @@ +The following are notes describing the requirements of the Platform +Specific code necessary for constructing a Portable CCAPI. + +Directory structure: + + lib/ccapi/client - platform independent client library + lib/ccapi/common - platform independent common library + lib/ccapi/include - platform independent header files + lib/ccapi/mac - macosx specific headers, libraries, executables + lib/ccapi/server - platform independent server library + lib/ccapi/windows - windows specific headers, libraries, executables + + +Platform Independent Design: + +The functionality of the Portable CCAPI is implemented in the platform +independent libraries. The common library encapsulates the functions +for managing generic lists, iterators, and messages as well as routines +formarshalling and unmarshalling. The client library provides the +client side routines for issuing requests to the ccapi server minus the +platform dependent glue required for shared library initialization, +cleanup, and interprocess communications. The server library provides +server side functionality for managing credential cache collections, +caches, credentials, iterators, and their handles minus the platform +dependent glue for process initialization, interprocess communication, +session security, and critical section enforcement. + + +Platform Dependent Design Requirements: + +The platform dependent code is responsible for producing a shared +client library: + + + the shared library is built from cc_client.lib and cc_common.lib plus + platform dependent glue + + - [windows] link cc_client.lib and cc_common.lib with platform + dependent routines and export list (.def) to produce + krbcc32.{lib,dll} + + + initialization and cleanup + + - [windows] provide DllMain entry point providing Process and Thread + attachment and detachment routines + + + implement cci_perform_rpc() function used by cc_client.lib + cc_int32 cci_perform_rpc(cc_msg_t *request, cc_msg_t **response) + + - cci_perform_rpc() takes an input request cc_msg_t object, flattens + it with cci_msg_flatten() and sends the contents of unsigned char + buffer request->flat of length request->flat_len to the server + utilizing a platform specific interprocess communication method. + + - upon IPC success, cci_perform_rpc() unflattens the response buffer + with cci_msg_unflatten() and returns the new cc_msg_t response + object to the caller. + + - cci_perform_rpc() is responsible for performing any necessary + session security management. For example, on Windows the Logon + Provider executes under the local machine's "SYSTEM" account within + session 0 and not under the account of the user that is logging in + nor within the session the user's desktop and applications will be + running within. It is the responsibility of cci_perform_rpc() and + the platform dependent IPC mechanism to communicate the user's + security identifiers to the server. + + For Windows, this means that the platform specific IPC messaging + allows a username and session identifier to be sent separate from + the username and session identifier that will be obtained via the + use of Local RPC. If the Local RPC authenticates the user as + "SYSTEM" and session 0, then the communicated values (if provided) + will be used instead. + + + implement client side of IPC routine. + + - [windows] the client side IPC routine is produced by compiling a + IDL file. The IDL defines an interface with a single function: + + __int32 ccapi_Message ( + [in] handle_t h, + [in, string] unsigned char * client_name, + [in] struct _LUID luid, + [in] __int32 in_len, + [in, string, size_is(in_len)] unsigned char * in_buf, + [in] __int32 out_size, + [out] __int32 * out_len, + [out, string, size_is(out_size)] unsigned char + out_buf[*]); + + The handle is a Local RPC specific handle used to identify the + request. The client_name and luid are the override values for the + username and session identifier for use during Windows login. The + rest of the parameters provide the input and output buffers as well + as allow communication of the actual length of the message data + that is required by cci_msg_unflatten(). + + + if the CCAPI server is per-session, the shared client library is + responsible for ensuring that an instance of the server is running in + the current session. If not, the library must initiate an instance + of the CCAPI server prior to performing any IPC requests. + +The platform dependent code is responsible for producing a server +executable: + + + The server executable is built from cc_server.lib and cc_common.lib + plus platform dependent glue. + + - [windows] The Windows CCAPI Server is being built using the + per-system model. The platform specific code is responsible for + providing NT Service Management routines for installation and + removal as well as the NT Service Entry Points used when the + process is started as an NT Service. + + link cc_server.lib and cc_common.lib with platform dependent + routines to produce krbcc32s.exe. + + + Based upon the platform requirements, the server may be constructed + to be per-session or per-system. The selected IPC mechanism must + enforce the appropriate scoping. + + + The platform dependent startup routines will perform platform + specific initialization including the IPC engine and call the + platform independent initialization routine ccs_serv_initialize() + + + The platform dependent shutdown routines will perform platform + specific cleanup including the IPC engine and call the platform + independent function ccs_serv_cleanup() prior to process termination. + + + For each inbound CCAPI request, the server will unmarshall the + request using cci_msg_unflatten() to produce a cc_msg_t object, + construct cc_auth_info_t and cc_session_info_t objects to represent + the platform dependent authentication and session data, call + ccs_serv_process_msg() to process the request, call cci_msg_flatten() + to marhall the response, transmit the response to the caller, and + then cleanup the request and response cc_msg_t objects with + cci_msg_destroy(). + + + The cc_auth_info_t and cc_session_info_t objects are structures + storing opaque binary (data, length) representations of the + authentication and session data. These are stored as part of ccache + collection and ccaches. ccs_serv_process_msg() will perform a binary + comparison of the stored data with the data provided in the current + request. If they do not match, the request will be denied. It is + necessary that the data generated data always be the same. If + username strings are not case-sensitive, they should be normalized + before being passed to ccs_serv_process_msg(). + + + The current cc_server.lib routines assume that one request at a time + is being processed. If the IPC engine allows for more than one + request to be simultaneously received in separate threads, then the + call to ccs_serv_process_msg() must be wrapped by a critical section. + Future enhancements to cc_server.lib will allow for per-object + mutexes. When available the platform specific glue must provide + functions to create, obtain, release, and destroy mutex objects. + + diff --git a/src/lib/ccapi/include/CredentialsCache.h b/src/lib/ccapi/include/CredentialsCache.h index dd60fa46d6..95c4fe79ba 100644 --- a/src/lib/ccapi/include/CredentialsCache.h +++ b/src/lib/ccapi/include/CredentialsCache.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 1998-2004 by the Massachusetts Institute of Technology. + * Copyright 1998-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -46,12 +46,12 @@ /* * Declarations for Credentials Cache API Library * - * API specification: + * API specification: * * Revision 1: Frank Dabek, 6/4/1998 * Revision 2: meeroh, 2/24/1999 * Revision 3: meeroh, 11/12/1999 - * Revision 4: jaltman, 10/27/2004 + * Revision 6: jaltman, 10/27/2004 * */ @@ -59,14 +59,11 @@ #define __CREDENTIALSCACHE__ #if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__)) - #include - #if TARGET_RT_MAC_CFM - #error "Use KfM 4.0 SDK headers for CFM compilation." - #endif +#include #endif -#if TARGET_OS_MAC - #include +#if defined(_WIN32) +#include #endif #ifdef __cplusplus @@ -74,11 +71,20 @@ extern "C" { #endif /* __cplusplus */ #if TARGET_OS_MAC - #if defined(__MWERKS__) - #pragma import on - #pragma enumsalwaysint on - #endif - #pragma options align=mac68k +#pragma options align=mac68k +#endif + +#if defined(_WIN32) +#define CCACHE_API __declspec(dllexport) + +#if _INTEGRAL_MAX_BITS >= 64 && _MSC_VER >= 1400 && !defined(_WIN64) && !defined(_USE_32BIT_TIME_T) +#if defined(_TIME_T_DEFINED) || defined(_INC_IO) || defined(_INC_TIME) || defined(_INC_WCHAR) +#error time_t has been defined as a 64-bit integer which is incompatible with Kerberos on this platform. +#endif /* _TIME_T_DEFINED */ +#define _USE_32BIT_TIME_T +#endif +#else +#define CCACHE_API #endif #include @@ -92,14 +98,16 @@ enum { ccapi_version_2 = 2, ccapi_version_3 = 3, ccapi_version_4 = 4, - ccapi_version_5 = 5 + ccapi_version_5 = 5, + ccapi_version_6 = 6, + ccapi_version_max = ccapi_version_6 }; /* Errors */ enum { - ccNoError = 0, + ccNoError = 0, - ccIteratorEnd = 201, + ccIteratorEnd = 201, ccErrBadParam, ccErrNoMem, ccErrInvalidContext, @@ -111,7 +119,7 @@ enum { ccErrInvalidCredentialsIterator, ccErrInvalidLock, - ccErrBadName, /* 211 */ + ccErrBadName, /* 211 */ ccErrBadCredentialsVersion, ccErrBadAPIVersion, ccErrContextLocked, @@ -123,7 +131,7 @@ enum { ccErrNeverDefault, ccErrCredentialsNotFound, - ccErrCCacheNotFound, /* 221 */ + ccErrCCacheNotFound, /* 221 */ ccErrContextNotFound, ccErrServerUnavailable, ccErrServerInsecure, @@ -135,20 +143,22 @@ enum { }; /* Credentials versions */ -enum { +enum cc_credential_versions { cc_credentials_v4 = 1, cc_credentials_v5 = 2, cc_credentials_v4_v5 = 3 }; /* Lock types */ -enum { - cc_lock_read = 1, - cc_lock_write = 2 +enum cc_lock_types { + cc_lock_read = 0, + cc_lock_write = 1, + cc_lock_upgrade = 2, + cc_lock_downgrade = 3 }; /* Locking Modes */ -enum { +enum cc_lock_modes { cc_lock_noblock = 0, cc_lock_block = 1 }; @@ -157,12 +167,20 @@ enum { * Basic types */ -typedef char cc_int8; -typedef unsigned char cc_uint8; -typedef int cc_int32; -typedef unsigned int cc_uint32; -typedef time_t cc_time_t; -typedef void * cc_handle; +typedef char cc_int8; +typedef unsigned char cc_uint8; +typedef int cc_int32; +typedef unsigned int cc_uint32; +#if defined (WIN32) +typedef __int64 cc_int64; +typedef unsigned __int64 cc_uint64; +#else +typedef long long cc_int64; +typedef unsigned long long cc_uint64; +#endif +typedef time_t cc_time; +typedef cc_int64 cc_time64; +typedef cc_uint64 cc_handle; /* * API types @@ -190,10 +208,11 @@ typedef struct cc_credentials_f cc_credentials_f; /* Credentials types */ enum { /* Make sure all of these are multiples of four (for alignment sanity) */ - cc_v4_name_size = 40, + cc_v4_name_size = 40, cc_v4_instance_size = 40, cc_v4_realm_size = 40, - cc_v4_ticket_size = 1254 + cc_v4_ticket_size = 1254, + cc_v4_key_size = 8 }; enum cc_string_to_key_type { @@ -211,10 +230,10 @@ struct cc_credentials_v4_t { char service [cc_v4_name_size]; char service_instance [cc_v4_instance_size]; char realm [cc_v4_realm_size]; - unsigned char session_key [8]; + unsigned char session_key [cc_v4_key_size]; cc_int32 kvno; cc_int32 string_to_key_type; - cc_time_t issue_date; + cc_time issue_date; cc_int32 lifetime; cc_uint32 address; cc_int32 ticket_size; @@ -233,10 +252,10 @@ struct cc_credentials_v5_t { char* client; char* server; cc_data keyblock; - cc_time_t authtime; - cc_time_t starttime; - cc_time_t endtime; - cc_time_t renew_till; + cc_time authtime; + cc_time starttime; + cc_time endtime; + cc_time renew_till; cc_uint32 is_skey; cc_uint32 ticket_flags; cc_data** addresses; @@ -320,7 +339,7 @@ struct cc_context_f { cc_context_t context); cc_int32 (*get_change_time) ( cc_context_t context, - cc_time_t* time); + cc_time* time); cc_int32 (*get_default_ccache_name) ( cc_context_t context, cc_string_t* name); @@ -397,16 +416,16 @@ struct cc_ccache_f { cc_ccache_t destination); cc_int32 (*lock) ( cc_ccache_t ccache, - cc_uint32 block, - cc_uint32 lock_type); + cc_uint32 lock_type, + cc_uint32 block); cc_int32 (*unlock) ( cc_ccache_t ccache); cc_int32 (*get_last_default_time) ( cc_ccache_t ccache, - cc_time_t* time); + cc_time* time); cc_int32 (*get_change_time) ( cc_ccache_t ccache, - cc_time_t* time); + cc_time* time); cc_int32 (*compare) ( cc_ccache_t ccache, cc_ccache_t compare_to, @@ -414,11 +433,11 @@ struct cc_ccache_f { cc_int32 (*get_kdc_time_offset) ( cc_ccache_t ccache, cc_int32 credentials_version, - cc_time_t* time_offset); + cc_time* time_offset); cc_int32 (*set_kdc_time_offset) ( cc_ccache_t ccache, cc_int32 credentials_version, - cc_time_t time_offset); + cc_time time_offset); cc_int32 (*clear_kdc_time_offset) ( cc_ccache_t ccache, @@ -446,6 +465,9 @@ struct cc_ccache_iterator_f { cc_int32 (*next) ( cc_ccache_iterator_t iter, cc_ccache_t* ccache); + + cc_int32 (*clone) ( cc_ccache_iterator_t iter, + cc_ccache_iterator_t* new_iter); }; struct cc_credentials_iterator_f { @@ -453,17 +475,20 @@ struct cc_credentials_iterator_f { cc_credentials_iterator_t iter); cc_int32 (*next) ( cc_credentials_iterator_t iter, - cc_credentials_t* ccache); + cc_credentials_t* cred); + + cc_int32 (*clone) ( cc_credentials_iterator_t iter, + cc_credentials_iterator_t* new_iter); }; /* * API functions */ -cc_int32 cc_initialize ( +CCACHE_API cc_int32 cc_initialize ( cc_context_t* outContext, - cc_int32 inVersion, - cc_int32* outSupportedVersion, + cc_int32 inVersion, + cc_int32* outSupportedVersion, char const** outVendor); /* @@ -488,8 +513,8 @@ cc_int32 cc_initialize ( ((context) -> functions -> create_new_ccache (context, version, principal, ccache)) #define cc_context_new_ccache_iterator(context, iterator) \ ((context) -> functions -> new_ccache_iterator (context, iterator)) -#define cc_context_lock(context, type, lock) \ - ((context) -> functions -> lock (context, type, lock)) +#define cc_context_lock(context, type, block) \ + ((context) -> functions -> lock (context, type, block)) #define cc_context_unlock(context) \ ((context) -> functions -> unlock (context)) #define cc_context_compare(context, compare_to, equal) \ @@ -515,8 +540,8 @@ cc_int32 cc_initialize ( ((ccache) -> functions -> remove_credentials (ccache, credentials)) #define cc_ccache_new_credentials_iterator(ccache, iterator) \ ((ccache) -> functions -> new_credentials_iterator (ccache, iterator)) -#define cc_ccache_lock(ccache, lock) \ - ((ccache) -> functions -> lock (ccache, lock)) +#define cc_ccache_lock(ccache, type, block) \ + ((ccache) -> functions -> lock (ccache, type, block)) #define cc_ccache_unlock(ccache, unlock) \ ((ccache) -> functions -> unlock (ccache, unlock)) #define cc_ccache_get_last_default_time(ccache, time) \ @@ -528,11 +553,11 @@ cc_int32 cc_initialize ( #define cc_ccache_compare(ccache, compare_to, equal) \ ((ccache) -> functions -> compare (ccache, compare_to, equal)) #define cc_ccache_get_kdc_time_offset(ccache, version, time) \ - ((ccache) -> functions -> get_kdc_time_offset (version, time)) + ((ccache) -> functions -> get_kdc_time_offset (version, time)) #define cc_ccache_set_kdc_time_offset(ccache, version, time) \ - ((ccache) -> functions -> set_kdc_time_offset (version, time)) + ((ccache) -> functions -> set_kdc_time_offset (version, time)) #define cc_ccache_clear_kdc_time_offset(ccache, version) \ - ((ccache) -> functions -> clear_kdc_time_offset (version)) + ((ccache) -> functions -> clear_kdc_time_offset (version)) #define cc_string_release(string) \ ((string) -> functions -> release (string)) @@ -546,18 +571,18 @@ cc_int32 cc_initialize ( ((iterator) -> functions -> release (iterator)) #define cc_ccache_iterator_next(iterator, ccache) \ ((iterator) -> functions -> next (iterator, ccache)) +#define cc_ccache_iterator_clone(iterator, new_iter) \ + ((iterator) -> functions -> clone (iterator, new_iter)) #define cc_credentials_iterator_release(iterator) \ ((iterator) -> functions -> release (iterator)) #define cc_credentials_iterator_next(iterator, credentials) \ ((iterator) -> functions -> next (iterator, credentials)) +#define cc_credentials_iterator_clone(iterator, new_iter) \ + ((iterator) -> functions -> clone (iterator, new_iter)) #if TARGET_OS_MAC - #if defined(__MWERKS__) - #pragma enumsalwaysint reset - #pragma import reset - #endif - #pragma options align=reset +#pragma options align=reset #endif #ifdef __cplusplus diff --git a/src/lib/ccapi/include/CredentialsCache2.h b/src/lib/ccapi/include/CredentialsCache2.h index 401e093f43..5505bf29fe 100644 --- a/src/lib/ccapi/include/CredentialsCache2.h +++ b/src/lib/ccapi/include/CredentialsCache2.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 1998-2004 by the Massachusetts Institute of Technology. + * Copyright 1998-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -48,12 +48,10 @@ #ifndef __CREDENTIALSCACHE2__ #define __CREDENTIALSCACHE2__ -#include +#include "CredentialsCache.h" + #if defined(macintosh) || (defined(__MACH__) && defined(__APPLE__)) - #include - #if TARGET_RT_MAC_CFM - #error "Use KfM 4.0 SDK headers for CFM compilation." - #endif +#include #endif #ifdef __cplusplus @@ -61,13 +59,9 @@ extern "C" { #endif /* __cplusplus */ #if TARGET_OS_MAC - #if defined(__MWERKS__) - #pragma import on - #pragma enumsalwaysint on - #endif - #pragma options align=mac68k +#pragma options align=mac68k #endif - + /* Some old types get directly mapped to new types */ typedef cc_context_d apiCB; @@ -87,10 +81,10 @@ typedef struct cc_credentials_v5_compat { char* client; char* server; cc_data_compat keyblock; - cc_time_t authtime; - cc_time_t starttime; - cc_time_t endtime; - cc_time_t renew_till; + cc_time authtime; + cc_time starttime; + cc_time endtime; + cc_time renew_till; cc_uint32 is_skey; cc_uint32 ticket_flags; cc_data_compat** addresses; @@ -185,25 +179,32 @@ enum { CC_CRED_MAX }; -cc_int32 cc_shutdown ( +enum { + CC_LOCK_UNLOCK = 1, + CC_LOCK_READER = 2, + CC_LOCK_WRITER = 3, + CC_LOCK_NOBLOCK = 16 +}; + +CCACHE_API cc_int32 cc_shutdown ( apiCB** ioContext); -cc_int32 cc_get_NC_info ( +CCACHE_API cc_int32 cc_get_NC_info ( apiCB* inContext, infoNC*** outInfo); -cc_int32 cc_get_change_time ( +CCACHE_API cc_int32 cc_get_change_time ( apiCB* inContext, - cc_time_t* outTime); + cc_time* outTime); -cc_int32 cc_open ( +CCACHE_API cc_int32 cc_open ( apiCB* inContext, const char* inName, cc_int32 inVersion, cc_uint32 inFlags, ccache_p** outCCache); -cc_int32 cc_create ( +CCACHE_API cc_int32 cc_create ( apiCB* inContext, const char* inName, const char* inPrincipal, @@ -211,94 +212,95 @@ cc_int32 cc_create ( cc_uint32 inFlags, ccache_p** outCCache); -cc_int32 cc_close ( +CCACHE_API cc_int32 cc_close ( apiCB* inContext, ccache_p** ioCCache); -cc_int32 cc_destroy ( +CCACHE_API cc_int32 cc_destroy ( apiCB* inContext, ccache_p** ioCCache); -cc_int32 cc_seq_fetch_NCs_begin ( +CCACHE_API cc_int32 cc_seq_fetch_NCs_begin ( apiCB* inContext, - ccache_cit** outIterator); + ccache_cit** outIterator); -cc_int32 cc_seq_fetch_NCs_next ( +CCACHE_API cc_int32 cc_seq_fetch_NCs_next ( apiCB* inContext, ccache_p** outCCache, ccache_cit* inIterator); -cc_int32 cc_seq_fetch_NCs_end ( +CCACHE_API cc_int32 cc_seq_fetch_NCs_end ( apiCB* inContext, - ccache_cit** ioIterator); + ccache_cit** ioIterator); -cc_int32 cc_get_name ( +CCACHE_API cc_int32 cc_get_name ( apiCB* inContext, ccache_p* inCCache, char** outName); -cc_int32 cc_get_cred_version ( +CCACHE_API cc_int32 cc_get_cred_version ( apiCB* inContext, ccache_p* inCCache, cc_int32* outVersion); -cc_int32 cc_set_principal ( +CCACHE_API cc_int32 cc_set_principal ( apiCB* inContext, ccache_p* inCCache, cc_int32 inVersion, char* inPrincipal); -cc_int32 cc_get_principal ( +CCACHE_API cc_int32 cc_get_principal ( apiCB* inContext, ccache_p* inCCache, char** outPrincipal); -cc_int32 cc_store ( +CCACHE_API cc_int32 cc_store ( apiCB* inContext, ccache_p* inCCache, cred_union inCredentials); -cc_int32 cc_remove_cred ( +CCACHE_API cc_int32 cc_remove_cred ( apiCB* inContext, ccache_p* inCCache, cred_union inCredentials); -cc_int32 cc_seq_fetch_creds_begin ( +CCACHE_API cc_int32 cc_seq_fetch_creds_begin ( apiCB* inContext, - const ccache_p* inCCache, - ccache_cit** outIterator); + const ccache_p* inCCache, + ccache_cit** outIterator); -cc_int32 cc_seq_fetch_creds_next ( +CCACHE_API cc_int32 cc_seq_fetch_creds_next ( apiCB* inContext, - cred_union** outCreds, + cred_union** outCreds, ccache_cit* inIterator); -cc_int32 cc_seq_fetch_creds_end ( +CCACHE_API cc_int32 cc_seq_fetch_creds_end ( apiCB* inContext, - ccache_cit** ioIterator); + ccache_cit** ioIterator); -cc_int32 cc_free_principal ( +CCACHE_API cc_int32 cc_free_principal ( apiCB* inContext, char** ioPrincipal); -cc_int32 cc_free_name ( +CCACHE_API cc_int32 cc_free_name ( apiCB* inContext, char** ioName); -cc_int32 cc_free_creds ( +CCACHE_API cc_int32 cc_free_creds ( apiCB* inContext, - cred_union** creds); + cred_union** creds); -cc_int32 cc_free_NC_info ( +CCACHE_API cc_int32 cc_free_NC_info ( apiCB* inContext, infoNC*** ioInfo); +CCACHE_API cc_int32 cc_lock_request( + apiCB* inContext, + const ccache_p* inCCache, + const cc_int32 lock_type); + #if TARGET_OS_MAC - #if defined(__MWERKS__) - #pragma enumsalwaysint reset - #pragma import reset - #endif - #pragma options align=reset +#pragma options align=reset #endif #ifdef __cplusplus diff --git a/src/lib/ccapi/include/cc_rpc.h b/src/lib/ccapi/include/cc_rpc.h new file mode 100644 index 0000000000..0f14724b90 --- /dev/null +++ b/src/lib/ccapi/include/cc_rpc.h @@ -0,0 +1,52 @@ +/* $Copyright: + * + * Copyright 2004-2006 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 MIT 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. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Individual source code files are copyright MIT, Cygnus Support, + * OpenVision, Oracle, Sun Soft, FundsXpress, and others. + * + * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, + * and Zephyr are trademarks of the Massachusetts Institute of Technology + * (MIT). No commercial use of these trademarks may be made without prior + * written permission of MIT. + * + * "Commercial use" means use of a name in a product or other for-profit + * manner. It does NOT prevent a commercial firm from referring to the MIT + * trademarks in order to convey information (although in doing so, + * recognition of their trademark status should be given). + * $ + */ + + +#ifndef __CC_RPC_H__ +#define __CC_RPC_H__ + +#include "msg.h" + +cc_int32 cci_perform_rpc(cc_msg_t *request, cc_msg_t **response); + +#endif /* __CC_RPC_H__ */ diff --git a/src/lib/ccapi/server/datastore.h b/src/lib/ccapi/include/datastore.h similarity index 52% rename from src/lib/ccapi/server/datastore.h rename to src/lib/ccapi/include/datastore.h index a92c60636b..7bb8b093d8 100644 --- a/src/lib/ccapi/server/datastore.h +++ b/src/lib/ccapi/include/datastore.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -51,43 +51,7 @@ #include "CredentialsCache.h" #include "rpc_auth.h" - -enum cc_list_type { - generic = 0, - context, - cache, - credentials -}; - -struct cc_generic_list_node_t { - cc_uint8* data; - cc_uint32 len; - struct cc_generic_list_node_t* next; - struct cc_generic_list_node_t* prev; -}; -typedef struct cc_generic_list_node_t cc_generic_list_node_t; - -struct cc_generic_list_head_t { - enum cc_list_type type; - cc_generic_list_node_t* head; - cc_generic_list_node_t* tail; -}; -typedef struct cc_generic_list_head_t cc_generic_list_head_t; - - -struct cc_generic_iterate_t { - cc_generic_list_node_t* next; -}; -typedef struct cc_generic_iterate_t cc_generic_iterate_t; - -typedef cc_generic_list_head_t cc_context_list_head_t; -typedef cc_generic_list_node_t cc_context_list_node_t; - -typedef cc_generic_list_head_t cc_ccache_list_head_t; -typedef cc_generic_list_node_t cc_ccache_list_node_t; - -typedef cc_generic_list_head_t cc_credentials_list_head_t; -typedef cc_generic_list_node_t cc_credentials_list_node_t; +#include "generic_lists.h" struct cc_context_iterate_t { cc_context_list_node_t* next; @@ -104,7 +68,7 @@ struct cc_credentials_iterate_t { }; typedef struct cc_credentials_iterate_t cc_credentials_iterate_t; -struct cc_lock_t { +struct cc_lock { cc_uint32 read_locks; /* count of read locks (>= 0) */ cc_uint32 write_locks; /* count of write locks (0 or 1) */ void * platform_data; /* platform specific implementation data */ @@ -118,7 +82,7 @@ struct cc_server_context_t { cc_int32 api_version; /*Version our client passed in on init (ccapi_version_X) */ cc_auth_info_t* auth_info; /*auth info passed in from RPC*/ cc_session_info_t* session_info; /*session info passed in from RPC*/ - cc_time_t changed; /*date of last change to this context*/ + cc_time64 changed; /*date of last change to this context*/ cc_int32 error; /*last error code*/ cc_lock_t locks; /*are we locked?*/ }; @@ -129,10 +93,10 @@ struct cc_server_ccache_t { char* principal_v4; /*v4 principal associated with this cache*/ char* principal_v5; /*v5 principal associated with this cache*/ cc_uint32 versions; /*versions of creds supported (from cc_credentials enum in CredentialsCache.h)*/ - cc_time_t changed; /*date of last change to ccache*/ + cc_time64 changed; /*date of last change to ccache*/ cc_int32 kdc_set; /*is the KDC time offset initialized?*/ - cc_time_t kdc_offset; /*offset of our clock relative kdc*/ - cc_time_t last_default; /*the last date when we were default*/ + cc_time64 kdc_offset; /*offset of our clock relative kdc*/ + cc_time64 last_default; /*the last date when we were default*/ cc_int32 is_default; /*is this the default cred on this ccache?*/ cc_generic_list_head_t* active_iterators; /*iterators which clients have opened on this cache*/ cc_credentials_list_head_t* creds; /*list of creds stored in this ccache*/ @@ -150,82 +114,69 @@ typedef struct cc_server_credentials_t cc_server_credentials_t; /*Note: cci means Credential Cache Internal, to differentiate from exported API macros*/ -cc_int32 cci_generic_iterate_has_next(cc_generic_iterate_t *iterate); -cc_int32 cci_generic_iterate_next(cc_generic_iterate_t *iterate, cc_generic_list_node_t**); - -cc_int32 cci_generic_list_new(cc_generic_list_head_t **); -cc_int32 cci_generic_list_append(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t**); -cc_int32 cci_generic_list_prepend(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t**); -cc_int32 cci_generic_list_remove_element(cc_generic_list_head_t* head, cc_generic_list_node_t* rem); -cc_int32 cci_generic_free_element(cc_generic_list_node_t* node); -cc_int32 cci_generic_list_destroy(cc_generic_list_head_t* head); -cc_int32 cci_generic_list_copy(cc_generic_list_head_t* head, cc_generic_list_head_t**); -cc_int32 cci_generic_list_iterator(cc_generic_list_head_t *head, cc_generic_iterate_t**); -cc_int32 cci_generic_free_iterator(cc_generic_iterate_t* iterator); - -cc_int32 cci_context_iterate_has_next(struct cc_context_iterate_t *iterate); -cc_int32 cci_context_iterate_next(struct cc_context_iterate_t *iterate, cc_context_list_node_t**); - -cc_int32 cci_ccache_iterate_has_next(struct cc_ccache_iterate_t *iterate); -cc_int32 cci_ccache_iterate_next(struct cc_ccache_iterate_t *iterate, cc_ccache_list_node_t**); - -cc_int32 cci_credentials_iterate_has_next(cc_credentials_iterate_t *iterate); -cc_int32 cci_credentials_iterate_next(cc_credentials_iterate_t *iterate, cc_credentials_list_node_t **); - -cc_int32 cci_context_list_new(cc_context_list_head_t**); -cc_int32 cci_context_list_append(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t**); -cc_int32 cci_context_list_prepend(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t**); -cc_int32 cci_context_list_remove_element(cc_context_list_head_t* head, cc_context_list_node_t* rem); -cc_int32 cci_context_list_iterator(cc_context_list_head_t *head, struct cc_context_iterate_t**); -cc_int32 cci_context_free_iterator(struct cc_context_iterate_t *iterator); -cc_int32 cci_context_list_destroy(cc_context_list_head_t* head) ; -cc_int32 cci_context_list_copy(cc_context_list_head_t* head, cc_context_list_head_t**); - -cc_int32 cci_ccache_list_new(cc_ccache_list_head_t**); -cc_int32 cci_ccache_list_append(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t**); -cc_int32 cci_ccache_list_prepend(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t**); -cc_int32 cci_ccache_list_remove_element(cc_ccache_list_head_t* head, cc_ccache_list_node_t* rem); -cc_int32 cci_ccache_list_iterator(cc_ccache_list_head_t *head, struct cc_ccache_iterate_t**); -cc_int32 cci_ccache_free_iterator(struct cc_ccache_iterate_t *iterator); -cc_int32 cci_ccache_list_destroy(cc_ccache_list_head_t* head) ; -cc_int32 cci_ccache_list_copy(cc_ccache_list_head_t* head, cc_ccache_list_head_t**); - - -cc_int32 cci_credentials_list_new(cc_credentials_list_head_t**); -cc_int32 cci_credentials_list_append(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t**); -cc_int32 cci_credentials_list_prepend(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t**); -cc_int32 cci_credentials_list_remove_element(cc_credentials_list_head_t* head, cc_credentials_list_node_t* rem); -cc_int32 cci_credentials_list_iterator(cc_credentials_list_head_t *head, cc_credentials_iterate_t**); -cc_int32 cci_credentials_free_iterator(cc_credentials_iterate_t* iterator); -cc_int32 cci_credentials_list_destroy(cc_credentials_list_head_t* head) ; -cc_int32 cci_credentials_list_copy(cc_credentials_list_head_t* head, cc_credentials_list_head_t**) ; - - -cc_int32 cci_context_new(int api_version, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** ) ; -cc_int32 cci_context_get_default_ccache_name(cc_server_context_t* ctx, char **); -cc_int32 cci_context_find_ccache(cc_server_context_t* ctx, char *name, cc_server_ccache_t**); -cc_int32 cci_context_open_ccache(cc_server_context_t* ctx, char *name, cc_server_ccache_t** ); -cc_int32 cci_context_create_ccache(cc_server_context_t* ctx, char *name, int creds_version, char *principal, cc_server_ccache_t**); -cc_int32 cci_context_create_default_ccache(cc_server_context_t* ctx, int creds_version, char *principal, cc_server_ccache_t**); -cc_int32 cci_context_ccache_iterator(cc_server_context_t* ctx, cc_ccache_iterate_t**); -cc_int32 cci_context_compare(cc_server_context_t* a, cc_server_context_t* b); -cc_int32 cci_context_destroy(cc_server_context_t* ctx); -cc_int32 cci_context_rem_ccache(cc_server_context_t* ctx, cc_server_ccache_t* ccache); - -cc_int32 cci_ccache_new(char *name, char *principal, int cred_vers, cc_server_ccache_t**); -cc_int32 cci_ccache_check_version(const cc_server_ccache_t *ccache, const cc_credentials_union* creds, cc_uint32* compat); -cc_int32 cci_ccache_check_principal(const cc_server_ccache_t *ccache, const cc_credentials_union* creds, cc_uint32* compat); -cc_int32 cci_ccache_store_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials); -cc_int32 cci_ccache_rem_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials); -cc_int32 cci_ccache_move(cc_server_ccache_t *source, cc_server_ccache_t* destination); -cc_int32 cci_ccache_get_kdc_time_offset(cc_server_ccache_t* ccache, cc_time_t* offset); -cc_int32 cci_ccache_set_kdc_time_offset(cc_server_ccache_t* ccache, cc_time_t offset); -cc_int32 cci_ccache_clear_kdc_time_offset(cc_server_ccache_t* ccache); -cc_int32 cci_ccache_new_iterator(cc_server_ccache_t* ccache, cc_credentials_iterate_t** iterator); -cc_int32 cci_ccache_get_principal(cc_server_ccache_t* ccache, cc_int32 version, char ** principal); -cc_int32 cci_ccache_set_principal(cc_server_ccache_t* ccache, cc_int32 version, char * principal); -cc_int32 cci_ccache_free_principal(char * principal); -cc_int32 cci_ccache_destroy(cc_server_ccache_t* ccache); -void cci_ccache_changed(cc_server_ccache_t* ccache); -cc_int32 cci_ccache_compare(cc_server_ccache_t* ccache1, cc_server_ccache_t* ccache2, cc_uint32 *result); +cc_int32 ccs_context_iterate_has_next(struct cc_context_iterate_t *iterate); +cc_int32 ccs_context_iterate_next(struct cc_context_iterate_t *iterate, cc_context_list_node_t**); + +cc_int32 ccs_ccache_iterate_has_next(struct cc_ccache_iterate_t *iterate); +cc_int32 ccs_ccache_iterate_next(struct cc_ccache_iterate_t *iterate, cc_ccache_list_node_t**); + +cc_int32 ccs_credentials_iterate_has_next(cc_credentials_iterate_t *iterate); +cc_int32 ccs_credentials_iterate_next(cc_credentials_iterate_t *iterate, cc_credentials_list_node_t **); + +cc_int32 ccs_context_list_new(cc_context_list_head_t**); +cc_int32 ccs_context_list_append(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t**); +cc_int32 ccs_context_list_prepend(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t**); +cc_int32 ccs_context_list_remove_element(cc_context_list_head_t* head, cc_context_list_node_t* rem); +cc_int32 ccs_context_list_iterator(cc_context_list_head_t *head, struct cc_context_iterate_t**); +cc_int32 ccs_context_free_iterator(struct cc_context_iterate_t *iterator); +cc_int32 ccs_context_list_destroy(cc_context_list_head_t* head) ; +cc_int32 ccs_context_list_copy(cc_context_list_head_t* head, cc_context_list_head_t**); + +cc_int32 ccs_ccache_list_new(cc_ccache_list_head_t**); +cc_int32 ccs_ccache_list_append(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t**); +cc_int32 ccs_ccache_list_prepend(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t**); +cc_int32 ccs_ccache_list_remove_element(cc_ccache_list_head_t* head, cc_ccache_list_node_t* rem); +cc_int32 ccs_ccache_list_iterator(cc_ccache_list_head_t *head, struct cc_ccache_iterate_t**); +cc_int32 ccs_ccache_free_iterator(struct cc_ccache_iterate_t *iterator); +cc_int32 ccs_ccache_list_destroy(cc_ccache_list_head_t* head) ; +cc_int32 ccs_ccache_list_copy(cc_ccache_list_head_t* head, cc_ccache_list_head_t**); + + +cc_int32 ccs_credentials_list_new(cc_credentials_list_head_t**); +cc_int32 ccs_credentials_list_append(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t**); +cc_int32 ccs_credentials_list_prepend(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t**); +cc_int32 ccs_credentials_list_remove_element(cc_credentials_list_head_t* head, cc_credentials_list_node_t* rem); +cc_int32 ccs_credentials_list_iterator(cc_credentials_list_head_t *head, cc_credentials_iterate_t**); +cc_int32 ccs_credentials_free_iterator(cc_credentials_iterate_t* iterator); +cc_int32 ccs_credentials_list_destroy(cc_credentials_list_head_t* head) ; +cc_int32 ccs_credentials_list_copy(cc_credentials_list_head_t* head, cc_credentials_list_head_t**) ; + + +cc_int32 ccs_context_new(int api_version, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** ) ; +cc_int32 ccs_context_get_default_ccache_name(cc_server_context_t* ctx, char **); +cc_int32 ccs_context_find_ccache(cc_server_context_t* ctx, char *name, cc_server_ccache_t**); +cc_int32 ccs_context_open_ccache(cc_server_context_t* ctx, char *name, cc_server_ccache_t** ); +cc_int32 ccs_context_create_ccache(cc_server_context_t* ctx, char *name, int creds_version, char *principal, cc_server_ccache_t**); +cc_int32 ccs_context_create_default_ccache(cc_server_context_t* ctx, int creds_version, char *principal, cc_server_ccache_t**); +cc_int32 ccs_context_ccache_iterator(cc_server_context_t* ctx, cc_ccache_iterate_t**); +cc_int32 ccs_context_compare(cc_server_context_t* a, cc_server_context_t* b); +cc_int32 ccs_context_destroy(cc_server_context_t* ctx); +cc_int32 ccs_context_rem_ccache(cc_server_context_t* ctx, cc_server_ccache_t* ccache); + +cc_int32 ccs_ccache_new(char *name, char *principal, int cred_vers, cc_server_ccache_t**); +cc_int32 ccs_ccache_check_version(const cc_server_ccache_t *ccache, const cc_credentials_union* creds, cc_uint32* compat); +cc_int32 ccs_ccache_check_principal(const cc_server_ccache_t *ccache, const cc_credentials_union* creds, cc_uint32* compat); +cc_int32 ccs_ccache_store_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials); +cc_int32 ccs_ccache_rem_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials); +cc_int32 ccs_ccache_move(cc_server_ccache_t *source, cc_server_ccache_t* destination); +cc_int32 ccs_ccache_get_kdc_time_offset(cc_server_ccache_t* ccache, cc_time64* offset); +cc_int32 ccs_ccache_set_kdc_time_offset(cc_server_ccache_t* ccache, cc_time64 offset); +cc_int32 ccs_ccache_clear_kdc_time_offset(cc_server_ccache_t* ccache); +cc_int32 ccs_ccache_new_iterator(cc_server_ccache_t* ccache, cc_credentials_iterate_t** iterator); +cc_int32 ccs_ccache_get_principal(cc_server_ccache_t* ccache, cc_int32 version, char ** principal); +cc_int32 ccs_ccache_set_principal(cc_server_ccache_t* ccache, cc_int32 version, char * principal); +cc_int32 ccs_ccache_free_principal(char * principal); +cc_int32 ccs_ccache_destroy(cc_server_ccache_t* ccache); +void ccs_ccache_changed(cc_server_ccache_t* ccache); +cc_int32 ccs_ccache_compare(cc_server_ccache_t* ccache1, cc_server_ccache_t* ccache2, cc_uint32 *result); #endif /*__CCDATASTOREH__*/ diff --git a/src/lib/ccapi/include/generic_lists.h b/src/lib/ccapi/include/generic_lists.h new file mode 100644 index 0000000000..14b7ae28c3 --- /dev/null +++ b/src/lib/ccapi/include/generic_lists.h @@ -0,0 +1,102 @@ +/* $Copyright: + * + * Copyright 2004-2006 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 MIT 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. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Individual source code files are copyright MIT, Cygnus Support, + * OpenVision, Oracle, Sun Soft, FundsXpress, and others. + * + * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, + * and Zephyr are trademarks of the Massachusetts Institute of Technology + * (MIT). No commercial use of these trademarks may be made without prior + * written permission of MIT. + * + * "Commercial use" means use of a name in a product or other for-profit + * manner. It does NOT prevent a commercial firm from referring to the MIT + * trademarks in order to convey information (although in doing so, + * recognition of their trademark status should be given). + * $ + */ +/* + * Prototypes and data structures for datastore. + * + */ + + +#ifndef __CC_GENERIC_LISTS_H_ +#define __CC_GENERIC_LISTS_H_ + +enum cc_list_type { + generic = 0, + context, + cache, + credentials +}; + +struct cc_generic_list_node_t { + cc_uint8* data; + cc_uint32 len; + struct cc_generic_list_node_t* next; + struct cc_generic_list_node_t* prev; +}; +typedef struct cc_generic_list_node_t cc_generic_list_node_t; + +struct cc_generic_list_head_t { + enum cc_list_type type; + cc_generic_list_node_t* head; + cc_generic_list_node_t* tail; +}; +typedef struct cc_generic_list_head_t cc_generic_list_head_t; + + +struct cc_generic_iterate_t { + cc_generic_list_node_t* next; +}; +typedef struct cc_generic_iterate_t cc_generic_iterate_t; + +typedef cc_generic_list_head_t cc_context_list_head_t; +typedef cc_generic_list_node_t cc_context_list_node_t; + +typedef cc_generic_list_head_t cc_ccache_list_head_t; +typedef cc_generic_list_node_t cc_ccache_list_node_t; + +typedef cc_generic_list_head_t cc_credentials_list_head_t; +typedef cc_generic_list_node_t cc_credentials_list_node_t; + +cc_int32 cci_generic_iterate_has_next(cc_generic_iterate_t *iterate); +cc_int32 cci_generic_iterate_next(cc_generic_iterate_t *iterate, cc_generic_list_node_t**); + +cc_int32 cci_generic_list_new(cc_generic_list_head_t **); +cc_int32 cci_generic_list_append(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t**); +cc_int32 cci_generic_list_prepend(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t**); +cc_int32 cci_generic_list_remove_element(cc_generic_list_head_t* head, cc_generic_list_node_t* rem); +cc_int32 cci_generic_free_element(cc_generic_list_node_t* node); +cc_int32 cci_generic_list_destroy(cc_generic_list_head_t* head); +cc_int32 cci_generic_list_copy(cc_generic_list_head_t* head, cc_generic_list_head_t**); +cc_int32 cci_generic_list_iterator(cc_generic_list_head_t *head, cc_generic_iterate_t**); +cc_int32 cci_generic_free_iterator(cc_generic_iterate_t* iterator); + +#endif /* __CC_GENERIC_LISTS_H_ */ diff --git a/src/lib/ccapi/include/marshall.h b/src/lib/ccapi/include/marshall.h index 19b9463b08..ca6b12e968 100644 --- a/src/lib/ccapi/include/marshall.h +++ b/src/lib/ccapi/include/marshall.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -41,7 +41,6 @@ * $ */ -#define FLAT_CREDS_V5_VERSION 1 struct cc_flat_data { cc_uint32 type; cc_uint32 length; @@ -49,15 +48,16 @@ struct cc_flat_data { }; typedef struct cc_flat_data cc_flat_data; +#define FLAT_CREDS_V5_VERSION 1 struct cci_flat_creds_v5 { cc_uint32 version; /* version of this structure */ cc_flat_data client; cc_flat_data server; cc_flat_data keyblock; - cc_time_t authtime; - cc_time_t starttime; - cc_time_t endtime; - cc_time_t renew_till; + cc_time64 authtime; + cc_time64 starttime; + cc_time64 endtime; + cc_time64 renew_till; cc_uint32 is_skey; cc_uint32 ticket_flags; cc_uint32 address_count; @@ -67,6 +67,25 @@ struct cci_flat_creds_v5 { cc_uint32 authdata_count; cc_uint32 authdata; /* offset to array */ }; +typedef struct cci_flat_creds_v5 cci_flat_creds_v5_t; + +struct cci_flat_creds_v4 { + cc_uint32 version; + char principal [cc_v4_name_size]; + char principal_instance [cc_v4_instance_size]; + char service [cc_v4_name_size]; + char service_instance [cc_v4_instance_size]; + char realm [cc_v4_realm_size]; + unsigned char session_key [cc_v4_key_size]; + cc_int32 kvno; + cc_int32 string_to_key_type; + cc_time64 issue_date; + cc_int32 lifetime; + cc_uint32 address; + cc_int32 ticket_size; + unsigned char ticket [cc_v4_ticket_size]; +}; +typedef struct cci_flat_creds_v4 cci_flat_creds_v4_t; cc_int32 cci_creds_v4_marshall( cc_credentials_v4_t * creds, diff --git a/src/lib/ccapi/include/msg.h b/src/lib/ccapi/include/msg.h index 0d712d6664..79b9a7f72e 100644 --- a/src/lib/ccapi/include/msg.h +++ b/src/lib/ccapi/include/msg.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -43,7 +43,7 @@ /* * Verifiable, extensible message format. - * + * * Format: * * @@ -60,13 +60,13 @@ * If the header has variable length data it is included in the data blobs. * The header field has the offset from the beginning of the message of the 1st * byte of the data and the length of the data. - * */ #ifndef __CC_MSG_H__ #define __CC_MSG_H__ #include "CredentialsCache.h" +#include "generic_lists.h" struct cc_msg_t { cc_uint32 type; /*type of message*/ @@ -87,16 +87,15 @@ enum { ccmsg_CTX_RELEASE, ccmsg_CTX_GET_CHANGE_TIME, ccmsg_CTX_GET_DEFAULT_CCACHE_NAME, - ccmsg_CTX_COMPARE, + ccmsg_CTX_CCACHE_OPEN, + ccmsg_CTX_CCACHE_OPEN_DEFAULT, + ccmsg_CTX_CCACHE_CREATE, + ccmsg_CTX_CCACHE_CREATE_DEFAULT, + ccmsg_CTX_CCACHE_CREATE_UNIQUE, ccmsg_CTX_NEW_CCACHE_ITERATOR, ccmsg_CTX_LOCK, ccmsg_CTX_UNLOCK, - ccmsg_CTX_CLONE, - ccmsg_CCACHE_OPEN, - ccmsg_CCACHE_OPEN_DEFAULT, - ccmsg_CCACHE_CREATE, - ccmsg_CCACHE_CREATE_DEFAULT, - ccmsg_CCACHE_CREATE_UNIQUE, + ccmsg_CTX_COMPARE, ccmsg_CCACHE_RELEASE, ccmsg_CCACHE_DESTROY, ccmsg_CCACHE_SET_DEFAULT, @@ -104,29 +103,28 @@ enum { ccmsg_CCACHE_GET_NAME, ccmsg_CCACHE_GET_PRINCIPAL, ccmsg_CCACHE_SET_PRINCIPAL, - ccmsg_CCACHE_CREDS_ITERATOR, + ccmsg_CCACHE_NEW_CREDS_ITERATOR, ccmsg_CCACHE_STORE_CREDS, ccmsg_CCACHE_REM_CREDS, + ccmsg_CCACHE_MOVE, + ccmsg_CCACHE_LOCK, + ccmsg_CCACHE_UNLOCK, ccmsg_CCACHE_GET_LAST_DEFAULT_TIME, ccmsg_CCACHE_GET_CHANGE_TIME, - ccmsg_CCACHE_MOVE, ccmsg_CCACHE_COMPARE, ccmsg_CCACHE_GET_KDC_TIME_OFFSET, ccmsg_CCACHE_SET_KDC_TIME_OFFSET, ccmsg_CCACHE_CLEAR_KDC_TIME_OFFSET, ccmsg_CCACHE_ITERATOR_RELEASE, ccmsg_CCACHE_ITERATOR_NEXT, - ccmsg_CCACHE_LOCK, - ccmsg_CCACHE_UNLOCK, + ccmsg_CCACHE_ITERATOR_CLONE, ccmsg_CREDS_ITERATOR_RELEASE, ccmsg_CREDS_ITERATOR_NEXT, - ccmsg_CREDS_RELEASE, - ccmsg_CREDS_V4, - ccmsg_CREDS_V5 + ccmsg_CREDS_ITERATOR_CLONE }; #define CC_MSG_MAX_SIZE 1073741824 /*2^30*/ -#define CC_MSG_MAX_TYPE ccmsg_CREDS_V5 +#define CC_MSG_MAX_TYPE ccmsg_CREDS_ITERATOR_CLONE #define BLOB_LEN (sizeof(cc_uint32)) #define MAGIC_DATA_LEN (sizeof(cc_uint32)) #define MAGIC_HEAD_LEN (sizeof(cc_uint32)) @@ -141,6 +139,23 @@ cc_int32 cci_msg_flatten(cc_msg_t* msg, void **); cc_int32 cci_msg_calc_magic(void *flat, int flat_len, cc_uint32 * sizep); cc_int32 cci_msg_verify(void* flat, int flat_len, cc_uint32 * sizep); cc_int32 cci_msg_unflatten(void *flat, int flat_len, cc_msg_t** msgpp); -cc_int32 cci_msg_retrieve_blob(cc_msg_t* msg, cc_uint32 blob_offset, cc_uint32 blob_len, void **); +cc_int32 cci_msg_retrieve_blob(cc_msg_t* msg, cc_uint32 blob_offset, cc_uint32 blob_len, char **); cc_int32 cci_msg_destroy(cc_msg_t* msg); + +/* Add missing byte swapping macros for 64-bit values */ +#ifdef MAC +#define htonll(x) OSSwapHostToBigInt64(x) +#define ntohll(x) OSSwapBigToHostInt64(x) +#else +#ifdef _WIN32 +#ifdef _M_IX86 +#define htonll(x) _byteswap_uint64(x) +#define ntohll(x) _byteswap_uint64(x) +#else +#define htonll(x) (x) +#define ntohll(x) (x) +#endif +#endif +#endif + #endif /*__CC_MSG_H__*/ diff --git a/src/lib/ccapi/include/msg_headers.h b/src/lib/ccapi/include/msg_headers.h index a27c2d2f12..b5a9acd6d5 100644 --- a/src/lib/ccapi/include/msg_headers.h +++ b/src/lib/ccapi/include/msg_headers.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -57,6 +57,8 @@ * size divisible by 4. This is to ensure correct alignment * and stop different compilers from inserting padding bytes in * different places. + * + * All values are stored in network byte order. */ struct ccmsg_ctx_only_t { @@ -81,18 +83,18 @@ struct ccmsg_init_resp_t { typedef struct ccmsg_init_t ccmsg_init_t; typedef struct ccmsg_init_resp_t ccmsg_init_resp_t; -struct ccmsg_clone_t { +struct ccmsg_ctx_clone_t { cc_handle ctx; cc_uint32 in_version; /*client API version*/ }; -struct ccmsg_clone_resp_t { +struct ccmsg_ctx_clone_resp_t { cc_handle out_ctx; /*handle on this ctx*/ cc_uint32 out_version; /*server API version*/ cc_uint32 vendor_offset; /*offset of vendor blob*/ cc_uint32 vendor_length; /*length of vendor blob*/ }; -typedef struct ccmsg_clone_t ccmsg_clone_t; -typedef struct ccmsg_clone_resp_t ccmsg_clone_resp_t; +typedef struct ccmsg_ctx_clone_t ccmsg_ctx_clone_t; +typedef struct ccmsg_ctx_clone_resp_t ccmsg_ctx_clone_resp_t; struct ccmsg_ctx_release_t { cc_handle ctx; /*# of ctx to release*/ @@ -103,7 +105,7 @@ struct ccmsg_ctx_get_change_time_t { cc_handle ctx; }; struct ccmsg_ctx_get_change_time_resp_t { - cc_time_t time; + cc_time64 time; }; typedef struct ccmsg_ctx_get_change_time_t ccmsg_ctx_get_change_time_t; typedef struct ccmsg_ctx_get_change_time_resp_t ccmsg_ctx_get_change_time_resp_t; @@ -304,7 +306,7 @@ struct ccmsg_ccache_get_last_default_time_t { cc_handle ccache; }; struct ccmsg_ccache_get_last_default_time_resp_t { - cc_time_t last_default_time; + cc_time64 last_default_time; }; typedef struct ccmsg_ccache_get_last_default_time_t ccmsg_ccache_get_last_default_time_t; typedef struct ccmsg_ccache_get_last_default_time_resp_t ccmsg_ccache_get_last_default_time_resp_t; @@ -314,7 +316,7 @@ struct ccmsg_ccache_get_change_time_t { cc_handle ccache; }; struct ccmsg_ccache_get_change_time_resp_t { - cc_time_t time; + cc_time64 time; }; typedef struct ccmsg_ccache_get_change_time_t ccmsg_ccache_get_change_time_t; typedef struct ccmsg_ccache_get_change_time_resp_t ccmsg_ccache_get_change_time_resp_t; @@ -336,7 +338,7 @@ struct ccmsg_ccache_get_kdc_time_offset_t { cc_int32 creds_version; }; struct ccmsg_ccache_get_kdc_time_offset_resp_t { - cc_time_t offset; + cc_time64 offset; }; typedef struct ccmsg_ccache_get_kdc_time_offset_t ccmsg_ccache_get_kdc_time_offset_t; typedef struct ccmsg_ccache_get_kdc_time_offset_resp_t ccmsg_ccache_get_kdc_time_offset_resp_t; @@ -344,7 +346,7 @@ typedef struct ccmsg_ccache_get_kdc_time_offset_resp_t ccmsg_ccache_get_kdc_time struct ccmsg_ccache_set_kdc_time_offset_t { cc_handle ctx; cc_handle ccache; - cc_time_t offset; + cc_time64 offset; cc_int32 creds_version; }; typedef struct ccmsg_ccache_set_kdc_time_offset_t ccmsg_ccache_set_kdc_time_offset_t; @@ -372,6 +374,16 @@ struct ccmsg_ccache_iterator_next_resp_t { typedef struct ccmsg_ccache_iterator_next_t ccmsg_ccache_iterator_next_t; typedef struct ccmsg_ccache_iterator_next_resp_t ccmsg_ccache_iterator_next_resp_t; +struct ccmsg_ccache_iterator_clone_t { + cc_handle ctx; + cc_handle iterator; +}; +struct ccmsg_ccache_iterator_clone_resp_t { + cc_handle iterator; +}; +typedef struct ccmsg_ccache_iterator_clone_t ccmsg_ccache_iterator_clone_t; +typedef struct ccmsg_ccache_iterator_clone_resp_t ccmsg_ccache_iterator_clone_resp_t; + struct ccmsg_creds_iterator_release_t { cc_handle ctx; cc_handle ccache; @@ -393,37 +405,14 @@ struct ccmsg_creds_iterator_next_resp_t { typedef struct ccmsg_creds_iterator_next_t ccmsg_creds_iterator_next_t; typedef struct ccmsg_creds_iterator_next_resp_t ccmsg_creds_iterator_next_resp_t; -struct ccmsg_creds_v4_t { - cc_uint32 offset; - cc_uint32 len; -}; -typedef struct ccmsg_creds_v4_t ccmsg_creds_v4_t; - -struct ccmsg_creds_v5_t { - cc_uint32 client_offset; - cc_uint32 client_len; - cc_uint32 server_offset; - cc_uint32 server_len; - cc_uint32 keyblock_offset; - cc_uint32 keyblock_len; - cc_time_t authtime; - cc_time_t starttime; - cc_time_t endtime; - cc_time_t renewtime; - cc_uint32 is_skey; - cc_uint32 ticket_flags; - cc_uint32 address_count; - cc_uint32 address_offset; - cc_uint32 address_len; - cc_uint32 ticket_offset; - cc_uint32 ticket_len; - cc_uint32 ticket2_offset; - cc_uint32 ticket2_len; - cc_uint32 authdata_count; - cc_uint32 authdata_offset; - cc_uint32 authdata_len; -}; -typedef struct ccmsg_creds_v5_t ccmsg_creds_v5_t; - +struct ccmsg_creds_iterator_clone_t { + cc_handle ctx; + cc_handle iterator; +}; +struct ccmsg_creds_iterator_clone_resp_t { + cc_handle iterator; +}; +typedef struct ccmsg_creds_iterator_clone_t ccmsg_creds_iterator_clone_t; +typedef struct ccmsg_creds_iterator_clone_resp_t ccmsg_creds_iterator_clone_resp_t; #endif /*__MSG_HEADERS_H__*/ diff --git a/src/lib/ccapi/server/rpc_auth.h b/src/lib/ccapi/include/rpc_auth.h similarity index 95% rename from src/lib/ccapi/server/rpc_auth.h rename to src/lib/ccapi/include/rpc_auth.h index 21d7db501c..010a1e2a51 100644 --- a/src/lib/ccapi/server/rpc_auth.h +++ b/src/lib/ccapi/include/rpc_auth.h @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -66,6 +66,6 @@ struct cc_session_info_t { }; typedef struct cc_session_info_t cc_session_info_t; -cc_int32 cci_rpc_is_authorized(cc_auth_info_t* msg_auth, cc_session_info_t* msg_session, cc_auth_info_t* stored_auth, cc_session_info_t* stored_session, cc_uint32 *authorizedp); +cc_int32 ccs_rpc_is_authorized(cc_auth_info_t* msg_auth, cc_session_info_t* msg_session, cc_auth_info_t* stored_auth, cc_session_info_t* stored_session, cc_uint32 *authorizedp); #endif /*__RPC_AUTH_H__*/ diff --git a/src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.pbxuser b/src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.pbxuser new file mode 100644 index 0000000000..ea15e540b0 --- /dev/null +++ b/src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.pbxuser @@ -0,0 +1,2005 @@ +// !$*UTF8*$! +{ + 08FB7793FE84155DC02AAC07 /* Project object */ = { + activeBuildConfigurationName = Debug; + activeExecutable = A1E70D5E0A38B796007BE3E3 /* CCacheServer */; + activeTarget = A1E70D5C0A38B796007BE3E3 /* CCacheServer */; + addToTargets = ( + ); + breakpoints = ( + ); + breakpointsGroup = A1E70D500A38B5F3007BE3E3 /* XCBreakpointsBucket */; + codeSenseManager = A1E70CFE0A38B536007BE3E3 /* Code sense */; + executables = ( + A1E70D5E0A38B796007BE3E3 /* CCacheServer */, + ); + perUserDictionary = { + PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 811, + 20, + 48, + 43, + 43, + 20, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + PBXFileDataSource_Target_ColumnID, + ); + }; + PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { + PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; + PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; + PBXFileTableDataSourceColumnWidthsKey = ( + 20, + 200, + 608, + 20, + 48, + 43, + 43, + ); + PBXFileTableDataSourceColumnsKey = ( + PBXFileDataSource_FiletypeID, + PBXFileDataSource_Filename_ColumnID, + PBXTargetDataSource_PrimaryAttribute, + PBXFileDataSource_Built_ColumnID, + PBXFileDataSource_ObjectSize_ColumnID, + PBXFileDataSource_Errors_ColumnID, + PBXFileDataSource_Warnings_ColumnID, + ); + }; + PBXPerProjectTemplateStateSaveDate = 171582174; + PBXWorkspaceStateSaveDate = 171582174; + }; + perUserProjectItems = { + A1E70DF70A38C765007BE3E3 /* PBXTextBookmark */ = A1E70DF70A38C765007BE3E3 /* PBXTextBookmark */; + A1E70DF80A38C765007BE3E3 /* PBXTextBookmark */ = A1E70DF80A38C765007BE3E3 /* PBXTextBookmark */; + A1E70DF90A38C765007BE3E3 /* PBXTextBookmark */ = A1E70DF90A38C765007BE3E3 /* PBXTextBookmark */; + A1E70DFA0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70DFA0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70DFB0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70DFB0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70DFD0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70DFD0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E010A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E010A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E020A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E020A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E060A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E060A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E090A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E090A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E0A0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E0A0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E0B0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E0B0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E0C0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E0C0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E100A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E100A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E110A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E110A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E120A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E120A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E130A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E130A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E140A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E140A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E150A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E150A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E160A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E160A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E170A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E170A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E180A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E180A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E1B0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E1B0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E1E0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E1E0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E1F0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E1F0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E200A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E200A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E250A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E250A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E260A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E260A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E290A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E290A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E2A0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E2A0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E2B0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E2B0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E2D0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E2D0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E2E0A38C765007BE3E3 /* PBXTextBookmark */ = A1E70E2E0A38C765007BE3E3 /* PBXTextBookmark */; + A1E70E380A38C778007BE3E3 /* PBXTextBookmark */ = A1E70E380A38C778007BE3E3 /* PBXTextBookmark */; + A1E70E3D0A38C78C007BE3E3 /* PBXTextBookmark */ = A1E70E3D0A38C78C007BE3E3 /* PBXTextBookmark */; + A1E70E410A38C78C007BE3E3 /* PBXTextBookmark */ = A1E70E410A38C78C007BE3E3 /* PBXTextBookmark */; + A1E70E430A38C791007BE3E3 /* PBXTextBookmark */ = A1E70E430A38C791007BE3E3 /* PBXTextBookmark */; + A1E70E450A38C791007BE3E3 /* PBXTextBookmark */ = A1E70E450A38C791007BE3E3 /* PBXTextBookmark */; + A1E70E4A0A38C7BE007BE3E3 /* PBXTextBookmark */ = A1E70E4A0A38C7BE007BE3E3 /* PBXTextBookmark */; + A1E70E520A38C9FD007BE3E3 /* PBXTextBookmark */ = A1E70E520A38C9FD007BE3E3 /* PBXTextBookmark */; + A1E70E530A38C9FD007BE3E3 /* PBXTextBookmark */ = A1E70E530A38C9FD007BE3E3 /* PBXTextBookmark */; + A1E70E560A38C9FD007BE3E3 /* PBXTextBookmark */ = A1E70E560A38C9FD007BE3E3 /* PBXTextBookmark */; + A1E70E580A38C9FD007BE3E3 /* PBXTextBookmark */ = A1E70E580A38C9FD007BE3E3 /* PBXTextBookmark */; + A1E70E6F0A38CA08007BE3E3 /* PBXTextBookmark */ = A1E70E6F0A38CA08007BE3E3 /* PBXTextBookmark */; + A1E70E770A38CA55007BE3E3 /* PBXTextBookmark */ = A1E70E770A38CA55007BE3E3 /* PBXTextBookmark */; + A1E70E7D0A38CA55007BE3E3 /* PBXTextBookmark */ = A1E70E7D0A38CA55007BE3E3 /* PBXTextBookmark */; + A1E70E9C0A38CAF1007BE3E3 /* PBXTextBookmark */ = A1E70E9C0A38CAF1007BE3E3 /* PBXTextBookmark */; + A1E70EA80A38CB24007BE3E3 /* PBXTextBookmark */ = A1E70EA80A38CB24007BE3E3 /* PBXTextBookmark */; + A1E70EAB0A38CB24007BE3E3 /* PBXTextBookmark */ = A1E70EAB0A38CB24007BE3E3 /* PBXTextBookmark */; + A1E70EB50A38CB4D007BE3E3 /* PBXTextBookmark */ = A1E70EB50A38CB4D007BE3E3 /* PBXTextBookmark */; + A1E70EC30A38CC14007BE3E3 /* PBXTextBookmark */ = A1E70EC30A38CC14007BE3E3 /* PBXTextBookmark */; + A1E70ECB0A38CC4C007BE3E3 /* PBXTextBookmark */ = A1E70ECB0A38CC4C007BE3E3 /* PBXTextBookmark */; + A1E70ED70A38CCB6007BE3E3 /* PBXTextBookmark */ = A1E70ED70A38CCB6007BE3E3 /* PBXTextBookmark */; + A1E70EE20A38CCD6007BE3E3 /* PBXTextBookmark */ = A1E70EE20A38CCD6007BE3E3 /* PBXTextBookmark */; + A1E70EFE0A38CD66007BE3E3 /* PBXTextBookmark */ = A1E70EFE0A38CD66007BE3E3 /* PBXTextBookmark */; + A1E70F0F0A38CE21007BE3E3 /* PBXTextBookmark */ = A1E70F0F0A38CE21007BE3E3 /* PBXTextBookmark */; + A1E70F440A38D252007BE3E3 /* PBXTextBookmark */ = A1E70F440A38D252007BE3E3 /* PBXTextBookmark */; + A1E70F450A38D252007BE3E3 /* PBXTextBookmark */ = A1E70F450A38D252007BE3E3 /* PBXTextBookmark */; + A1E70F8B0A38D3B4007BE3E3 /* PBXTextBookmark */ = A1E70F8B0A38D3B4007BE3E3 /* PBXTextBookmark */; + A1E70F9C0A38D41E007BE3E3 /* PBXTextBookmark */ = A1E70F9C0A38D41E007BE3E3 /* PBXTextBookmark */; + A1E70F9D0A38D41E007BE3E3 /* PBXTextBookmark */ = A1E70F9D0A38D41E007BE3E3 /* PBXTextBookmark */; + A1E70FC60A38D560007BE3E3 /* PBXTextBookmark */ = A1E70FC60A38D560007BE3E3 /* PBXTextBookmark */; + A1E70FC80A38D560007BE3E3 /* PBXTextBookmark */ = A1E70FC80A38D560007BE3E3 /* PBXTextBookmark */; + A1E70FC90A38D560007BE3E3 /* PBXTextBookmark */ = A1E70FC90A38D560007BE3E3 /* PBXTextBookmark */; + A1E70FCA0A38D560007BE3E3 /* PBXTextBookmark */ = A1E70FCA0A38D560007BE3E3 /* PBXTextBookmark */; + A1E70FCD0A38D560007BE3E3 /* PBXTextBookmark */ = A1E70FCD0A38D560007BE3E3 /* PBXTextBookmark */; + A1E70FD80A38D573007BE3E3 /* PBXTextBookmark */ = A1E70FD80A38D573007BE3E3 /* PBXTextBookmark */; + A1E70FEE0A38D7C0007BE3E3 /* PBXTextBookmark */ = A1E70FEE0A38D7C0007BE3E3 /* PBXTextBookmark */; + A1E70FEF0A38D7C0007BE3E3 /* PBXTextBookmark */ = A1E70FEF0A38D7C0007BE3E3 /* PBXTextBookmark */; + A1E70FF00A38D7C0007BE3E3 /* PBXTextBookmark */ = A1E70FF00A38D7C0007BE3E3 /* PBXTextBookmark */; + A1E70FFA0A38D806007BE3E3 /* PBXTextBookmark */ = A1E70FFA0A38D806007BE3E3 /* PBXTextBookmark */; + A1E70FFC0A38D806007BE3E3 /* PBXTextBookmark */ = A1E70FFC0A38D806007BE3E3 /* PBXTextBookmark */; + A1E70FFF0A38D806007BE3E3 /* PBXTextBookmark */ = A1E70FFF0A38D806007BE3E3 /* PBXTextBookmark */; + A1E710010A38D814007BE3E3 /* PBXTextBookmark */ = A1E710010A38D814007BE3E3 /* PBXTextBookmark */; + A1E7100A0A38D888007BE3E3 /* PBXTextBookmark */ = A1E7100A0A38D888007BE3E3 /* PBXTextBookmark */; + A1E7100C0A38D888007BE3E3 /* PBXTextBookmark */ = A1E7100C0A38D888007BE3E3 /* PBXTextBookmark */; + A1E7100D0A38D888007BE3E3 /* PBXTextBookmark */ = A1E7100D0A38D888007BE3E3 /* PBXTextBookmark */; + A1E710110A38D888007BE3E3 /* PBXTextBookmark */ = A1E710110A38D888007BE3E3 /* PBXTextBookmark */; + A1E710140A38D888007BE3E3 /* PBXTextBookmark */ = A1E710140A38D888007BE3E3 /* PBXTextBookmark */; + A1E7103C0A38DE0B007BE3E3 /* PBXTextBookmark */ = A1E7103C0A38DE0B007BE3E3 /* PBXTextBookmark */; + A1E710400A38DE0B007BE3E3 /* PBXTextBookmark */ = A1E710400A38DE0B007BE3E3 /* PBXTextBookmark */; + A1E710530A39EC0B007BE3E3 /* PBXTextBookmark */ = A1E710530A39EC0B007BE3E3 /* PBXTextBookmark */; + A1E7105A0A39ED89007BE3E3 /* PBXTextBookmark */ = A1E7105A0A39ED89007BE3E3 /* PBXTextBookmark */; + A1E7105D0A39ED89007BE3E3 /* PBXTextBookmark */ = A1E7105D0A39ED89007BE3E3 /* PBXTextBookmark */; + A1E7105E0A39ED89007BE3E3 /* PBXTextBookmark */ = A1E7105E0A39ED89007BE3E3 /* PBXTextBookmark */; + A1E710680A39F102007BE3E3 /* PBXTextBookmark */ = A1E710680A39F102007BE3E3 /* PBXTextBookmark */; + A1E710840A3A1CFB007BE3E3 /* PBXTextBookmark */ = A1E710840A3A1CFB007BE3E3 /* PBXTextBookmark */; + A1E710860A3A1CFB007BE3E3 /* PBXTextBookmark */ = A1E710860A3A1CFB007BE3E3 /* PBXTextBookmark */; + A1E710870A3A1CFB007BE3E3 /* PBXTextBookmark */ = A1E710870A3A1CFB007BE3E3 /* PBXTextBookmark */; + A1E710890A3A1D04007BE3E3 /* PBXTextBookmark */ = A1E710890A3A1D04007BE3E3 /* PBXTextBookmark */; + A1E7108B0A3A1D04007BE3E3 /* PBXTextBookmark */ = A1E7108B0A3A1D04007BE3E3 /* PBXTextBookmark */; + A1E7108D0A3A1D06007BE3E3 /* PBXTextBookmark */ = A1E7108D0A3A1D06007BE3E3 /* PBXTextBookmark */; + A1E710930A3A1D22007BE3E3 /* PBXTextBookmark */ = A1E710930A3A1D22007BE3E3 /* PBXTextBookmark */; + A1E710940A3A1D22007BE3E3 /* PBXTextBookmark */ = A1E710940A3A1D22007BE3E3 /* PBXTextBookmark */; + A1E710950A3A1D22007BE3E3 /* PBXTextBookmark */ = A1E710950A3A1D22007BE3E3 /* PBXTextBookmark */; + A1E710960A3A1D22007BE3E3 /* PBXTextBookmark */ = A1E710960A3A1D22007BE3E3 /* PBXTextBookmark */; + A1E710970A3A1D22007BE3E3 /* PBXTextBookmark */ = A1E710970A3A1D22007BE3E3 /* PBXTextBookmark */; + A1E7109C0A3A1D2B007BE3E3 /* PBXTextBookmark */ = A1E7109C0A3A1D2B007BE3E3 /* PBXTextBookmark */; + A1E7109D0A3A1D2B007BE3E3 /* PBXTextBookmark */ = A1E7109D0A3A1D2B007BE3E3 /* PBXTextBookmark */; + A1E7109F0A3A1DD0007BE3E3 /* PBXTextBookmark */ = A1E7109F0A3A1DD0007BE3E3 /* PBXTextBookmark */; + A1E710A00A3A1DD0007BE3E3 /* PBXTextBookmark */ = A1E710A00A3A1DD0007BE3E3 /* PBXTextBookmark */; + A1E710A50A3A22E1007BE3E3 /* PBXTextBookmark */ = A1E710A50A3A22E1007BE3E3 /* PBXTextBookmark */; + A1E710AB0A3A22F5007BE3E3 /* PBXTextBookmark */ = A1E710AB0A3A22F5007BE3E3 /* PBXTextBookmark */; + A1E710AC0A3A22F5007BE3E3 /* PBXTextBookmark */ = A1E710AC0A3A22F5007BE3E3 /* PBXTextBookmark */; + A1E710AD0A3A22F5007BE3E3 /* PBXTextBookmark */ = A1E710AD0A3A22F5007BE3E3 /* PBXTextBookmark */; + A1E710AF0A3A22FE007BE3E3 /* PBXTextBookmark */ = A1E710AF0A3A22FE007BE3E3 /* PBXTextBookmark */; + A1E710B30A3A22FF007BE3E3 /* PBXTextBookmark */ = A1E710B30A3A22FF007BE3E3 /* PBXTextBookmark */; + A1E710B90A3A23FB007BE3E3 /* PBXTextBookmark */ = A1E710B90A3A23FB007BE3E3 /* PBXTextBookmark */; + A1E710BC0A3A2415007BE3E3 /* PBXTextBookmark */ = A1E710BC0A3A2415007BE3E3 /* PBXTextBookmark */; + A1E710BD0A3A2415007BE3E3 /* PBXTextBookmark */ = A1E710BD0A3A2415007BE3E3 /* PBXTextBookmark */; + A1E710BE0A3A2415007BE3E3 /* PBXTextBookmark */ = A1E710BE0A3A2415007BE3E3 /* PBXTextBookmark */; + A1E710BF0A3A2415007BE3E3 /* PBXTextBookmark */ = A1E710BF0A3A2415007BE3E3 /* PBXTextBookmark */; + A1E710C00A3A2415007BE3E3 /* PBXTextBookmark */ = A1E710C00A3A2415007BE3E3 /* PBXTextBookmark */; + A1E710C60A3A2441007BE3E3 /* PBXTextBookmark */ = A1E710C60A3A2441007BE3E3 /* PBXTextBookmark */; + A1E710C70A3A2441007BE3E3 /* PBXTextBookmark */ = A1E710C70A3A2441007BE3E3 /* PBXTextBookmark */; + A1E710C80A3A2441007BE3E3 /* PBXTextBookmark */ = A1E710C80A3A2441007BE3E3 /* PBXTextBookmark */; + A1E710C90A3A2441007BE3E3 /* PBXTextBookmark */ = A1E710C90A3A2441007BE3E3 /* PBXTextBookmark */; + A1E710CA0A3A244D007BE3E3 /* PBXTextBookmark */ = A1E710CA0A3A244D007BE3E3 /* PBXTextBookmark */; + A1E710CB0A3A244D007BE3E3 /* PBXTextBookmark */ = A1E710CB0A3A244D007BE3E3 /* PBXTextBookmark */; + A1E710CC0A3A244D007BE3E3 /* PBXTextBookmark */ = A1E710CC0A3A244D007BE3E3 /* PBXTextBookmark */; + A1E710CD0A3A244D007BE3E3 /* PBXTextBookmark */ = A1E710CD0A3A244D007BE3E3 /* PBXTextBookmark */; + A1E710CE0A3A244D007BE3E3 /* PBXTextBookmark */ = A1E710CE0A3A244D007BE3E3 /* PBXTextBookmark */; + A1E710D00A3A2456007BE3E3 /* PBXTextBookmark */ = A1E710D00A3A2456007BE3E3 /* PBXTextBookmark */; + A1E710D10A3A2456007BE3E3 /* PBXTextBookmark */ = A1E710D10A3A2456007BE3E3 /* PBXTextBookmark */; + A1E710D20A3A2456007BE3E3 /* PBXTextBookmark */ = A1E710D20A3A2456007BE3E3 /* PBXTextBookmark */; + A1E710D30A3A2456007BE3E3 /* PBXTextBookmark */ = A1E710D30A3A2456007BE3E3 /* PBXTextBookmark */; + A1E710D40A3A2456007BE3E3 /* PBXTextBookmark */ = A1E710D40A3A2456007BE3E3 /* PBXTextBookmark */; + A1E710D70A3A2465007BE3E3 /* PBXTextBookmark */ = A1E710D70A3A2465007BE3E3 /* PBXTextBookmark */; + A1E710D80A3A2465007BE3E3 /* PBXTextBookmark */ = A1E710D80A3A2465007BE3E3 /* PBXTextBookmark */; + A1E710D90A3A2465007BE3E3 /* PBXTextBookmark */ = A1E710D90A3A2465007BE3E3 /* PBXTextBookmark */; + A1E710DB0A3A246E007BE3E3 /* PBXTextBookmark */ = A1E710DB0A3A246E007BE3E3 /* PBXTextBookmark */; + A1E710DF0A3A247D007BE3E3 /* PBXTextBookmark */ = A1E710DF0A3A247D007BE3E3 /* PBXTextBookmark */; + A1E710E00A3A247D007BE3E3 /* PBXTextBookmark */ = A1E710E00A3A247D007BE3E3 /* PBXTextBookmark */; + A1E710E10A3A247D007BE3E3 /* PBXTextBookmark */ = A1E710E10A3A247D007BE3E3 /* PBXTextBookmark */; + A1E710E20A3A247D007BE3E3 /* PBXTextBookmark */ = A1E710E20A3A247D007BE3E3 /* PBXTextBookmark */; + A1E710E30A3A247D007BE3E3 /* PBXTextBookmark */ = A1E710E30A3A247D007BE3E3 /* PBXTextBookmark */; + A1E710E50A3A248A007BE3E3 /* PBXTextBookmark */ = A1E710E50A3A248A007BE3E3 /* PBXTextBookmark */; + A1E710E60A3A248A007BE3E3 /* PBXTextBookmark */ = A1E710E60A3A248A007BE3E3 /* PBXTextBookmark */; + A1E710E70A3A24A4007BE3E3 /* PBXTextBookmark */ = A1E710E70A3A24A4007BE3E3 /* PBXTextBookmark */; + A1E710E80A3A24A5007BE3E3 /* PBXTextBookmark */ = A1E710E80A3A24A5007BE3E3 /* PBXTextBookmark */; + A1E710E90A3A24A5007BE3E3 /* PBXTextBookmark */ = A1E710E90A3A24A5007BE3E3 /* PBXTextBookmark */; + A1E710EA0A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710EA0A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710EB0A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710EB0A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710EC0A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710EC0A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710ED0A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710ED0A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710EE0A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710EE0A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710EF0A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710EF0A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710F00A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710F00A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710F10A3A2521007BE3E3 /* PBXTextBookmark */ = A1E710F10A3A2521007BE3E3 /* PBXTextBookmark */; + A1E710F40A3A253F007BE3E3 /* PBXTextBookmark */ = A1E710F40A3A253F007BE3E3 /* PBXTextBookmark */; + A1E710F50A3A253F007BE3E3 /* PBXTextBookmark */ = A1E710F50A3A253F007BE3E3 /* PBXTextBookmark */; + }; + sourceControlManager = A1E70CFD0A38B536007BE3E3 /* Source Control */; + userBuildSettings = { + }; + }; + A1E70CFD0A38B536007BE3E3 /* Source Control */ = { + isa = PBXSourceControlManager; + fallbackIsa = XCSourceControlManager; + isSCMEnabled = 0; + scmConfiguration = { + }; + scmType = ""; + }; + A1E70CFE0A38B536007BE3E3 /* Code sense */ = { + isa = PBXCodeSenseManager; + indexTemplatePath = ""; + }; + A1E70D000A38B5BB007BE3E3 /* cacheapi.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1087, 2100}}"; + sepNavSelRange = "{4787, 139}"; + sepNavVisRect = "{{0, 1547}, {1087, 448}}"; + }; + }; + A1E70D010A38B5BB007BE3E3 /* ccache.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1003, 18424}}"; + sepNavSelRange = "{11919, 0}"; + sepNavVisRect = "{{0, 5185}, {1003, 481}}"; + }; + }; + A1E70D020A38B5BB007BE3E3 /* ccache.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {980, 2058}}"; + sepNavSelRange = "{2339, 9}"; + sepNavVisRect = "{{0, 556}, {980, 387}}"; + }; + }; + A1E70D080A38B5BB007BE3E3 /* context.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {980, 13958}}"; + sepNavSelRange = "{29891, 21}"; + sepNavVisRect = "{{0, 13156}, {980, 387}}"; + }; + }; + A1E70D0B0A38B5BB007BE3E3 /* credentials.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {621, 1330}}"; + sepNavSelRange = "{0, 2110}"; + sepNavVisRect = "{{0, 235}, {621, 499}}"; + }; + }; + A1E70D0C0A38B5BB007BE3E3 /* credentials_iterator.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {980, 3836}}"; + sepNavSelRange = "{6723, 21}"; + sepNavVisRect = "{{0, 2544}, {980, 387}}"; + }; + }; + A1E70D0F0A38B5BB007BE3E3 /* NTMakefile */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {734, 998}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {734, 998}}"; + sepNavWindowFrame = "{{15, 46}, {779, 1127}}"; + }; + }; + A1E70D120A38B5BB007BE3E3 /* generic_lists.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1003, 5572}}"; + sepNavSelRange = "{2282, 0}"; + sepNavVisRect = "{{0, 489}, {1003, 521}}"; + }; + }; + A1E70D130A38B5BB007BE3E3 /* marshall.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {980, 6188}}"; + sepNavSelRange = "{11995, 68}"; + sepNavVisRect = "{{0, 4756}, {980, 387}}"; + }; + }; + A1E70D140A38B5BB007BE3E3 /* msg.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1087, 8722}}"; + sepNavSelRange = "{15262, 21}"; + sepNavVisRect = "{{0, 7868}, {1087, 448}}"; + }; + }; + A1E70D150A38B5BB007BE3E3 /* NTMakefile */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {621, 499}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {621, 499}}"; + }; + }; + A1E70D190A38B5BB007BE3E3 /* cc_rpc.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {888, 742}}"; + sepNavSelRange = "{2202, 18}"; + sepNavVisRect = "{{0, 453}, {888, 289}}"; + }; + }; + A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1003, 8302}}"; + sepNavSelRange = "{2631, 0}"; + sepNavVisRect = "{{0, 958}, {1003, 521}}"; + }; + }; + A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1003, 4340}}"; + sepNavSelRange = "{7813, 0}"; + sepNavVisRect = "{{0, 422}, {1003, 521}}"; + }; + }; + A1E70D1C0A38B5BB007BE3E3 /* datastore.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {888, 2562}}"; + sepNavSelRange = "{2301, 0}"; + sepNavVisRect = "{{0, 573}, {888, 436}}"; + }; + }; + A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1003, 1442}}"; + sepNavSelRange = "{2369, 0}"; + sepNavVisRect = "{{0, 545}, {1003, 521}}"; + }; + }; + A1E70D1F0A38B5BB007BE3E3 /* msg.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1003, 2268}}"; + sepNavSelRange = "{5529, 0}"; + sepNavVisRect = "{{0, 1721}, {1003, 521}}"; + }; + }; + A1E70D260A38B5BB007BE3E3 /* NTMakefile */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {621, 499}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {621, 499}}"; + }; + }; + A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1003, 9856}}"; + sepNavSelRange = "{9783, 0}"; + sepNavVisRect = "{{0, 3674}, {1003, 730}}"; + }; + }; + A1E70D2C0A38B5BB007BE3E3 /* main.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {621, 910}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 134}, {621, 727}}"; + }; + }; + A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {1087, 22204}}"; + sepNavSelRange = "{36879, 21}"; + sepNavVisRect = "{{0, 14168}, {1087, 448}}"; + }; + }; + A1E70D3B0A38B5BB007BE3E3 /* client.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {804, 1988}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {804, 503}}"; + }; + }; + A1E70D460A38B5BC007BE3E3 /* server.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {621, 9520}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {621, 499}}"; + }; + }; + A1E70D500A38B5F3007BE3E3 /* XCBreakpointsBucket */ = { + isa = XCBreakpointsBucket; + name = CCAPI; + objects = ( + ); + }; + A1E70D5C0A38B796007BE3E3 /* CCacheServer */ = { + activeExec = 0; + executables = ( + A1E70D5E0A38B796007BE3E3 /* CCacheServer */, + ); + }; + A1E70D5E0A38B796007BE3E3 /* CCacheServer */ = { + isa = PBXExecutable; + activeArgIndex = 2147483647; + activeArgIndices = ( + ); + argumentStrings = ( + ); + autoAttachOnCrash = 1; + configStateDict = { + }; + customDataFormattersEnabled = 1; + debuggerPlugin = GDBDebugging; + disassemblyDisplayState = 0; + enableDebugStr = 1; + environmentEntries = ( + ); + executableSystemSymbolLevel = 0; + executableUserSymbolLevel = 0; + libgmallocEnabled = 0; + name = CCacheServer; + sourceDirectories = ( + ); + }; + A1E70D930A38BB67007BE3E3 /* main.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {980, 476}}"; + sepNavSelRange = "{316, 42}"; + sepNavVisRect = "{{0, 24}, {980, 387}}"; + }; + }; + A1E70D9E0A38BCAD007BE3E3 /* mig.defs */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {804, 826}}"; + sepNavSelRange = "{2123, 0}"; + sepNavVisRect = "{{0, 400}, {804, 391}}"; + }; + }; + A1E70DB10A38C01E007BE3E3 /* mig_types.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {804, 686}}"; + sepNavSelRange = "{2188, 0}"; + sepNavVisRect = "{{0, 281}, {804, 391}}"; + }; + }; + A1E70DE10A38C6FD007BE3E3 /* kipc_common.h */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {888, 1078}}"; + sepNavSelRange = "{1293, 0}"; + sepNavVisRect = "{{0, 206}, {888, 470}}"; + }; + }; + A1E70DE40A38C6FD007BE3E3 /* kipc_client.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {804, 1218}}"; + sepNavSelRange = "{1240, 34}"; + sepNavVisRect = "{{0, 235}, {804, 329}}"; + }; + }; + A1E70DE50A38C6FD007BE3E3 /* kipc_common.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {632, 1316}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {621, 499}}"; + }; + }; + A1E70DE60A38C6FD007BE3E3 /* kipc_server.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {728, 4396}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {621, 499}}"; + }; + }; + A1E70DE70A38C6FD007BE3E3 /* kipc_session.c */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {698, 1988}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {621, 499}}"; + }; + }; + A1E70DE80A38C6FD007BE3E3 /* notify.defs */ = { + uiCtxt = { + sepNavIntBoundsRect = "{{0, 0}, {621, 518}}"; + sepNavSelRange = "{0, 0}"; + sepNavVisRect = "{{0, 0}, {621, 499}}"; + }; + }; + A1E70DF70A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D150A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 308; + vrLoc = 0; + }; + A1E70DF80A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D3B0A38B5BB007BE3E3 /* client.c */; + name = "client.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 903; + vrLoc = 0; + }; + A1E70DF90A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D3C0A38B5BB007BE3E3 /* dllmain.c */; + name = "dllmain.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 298; + vrLoc = 0; + }; + A1E70DFA0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D3A0A38B5BB007BE3E3 /* cacheapi.def */; + name = "cacheapi.def: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 847; + vrLoc = 0; + }; + A1E70DFB0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D460A38B5BC007BE3E3 /* server.c */; + name = "server.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 756; + vrLoc = 0; + }; + A1E70DFD0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1826; + vrLoc = 0; + }; + A1E70E010A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D0B0A38B5BB007BE3E3 /* credentials.h */; + name = "credentials.h: 1"; + rLen = 2110; + rLoc = 0; + rType = 0; + vrLen = 1604; + vrLoc = 749; + }; + A1E70E020A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2C0A38B5BB007BE3E3 /* main.c */; + name = "main.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1306; + vrLoc = 202; + }; + A1E70E060A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */; + name = "CredentialsCache2.h: 303"; + rLen = 0; + rLoc = 7813; + rType = 0; + vrLen = 1128; + vrLoc = 6802; + }; + A1E70E090A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE80A38C6FD007BE3E3 /* notify.defs */; + name = "notify.defs: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1437; + vrLoc = 0; + }; + A1E70E0A0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE60A38C6FD007BE3E3 /* kipc_server.c */; + name = "kipc_server.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1538; + vrLoc = 0; + }; + A1E70E0B0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE70A38C6FD007BE3E3 /* kipc_session.c */; + name = "kipc_session.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1461; + vrLoc = 0; + }; + A1E70E0C0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE50A38C6FD007BE3E3 /* kipc_common.c */; + name = "kipc_common.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1496; + vrLoc = 0; + }; + A1E70E100A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D150A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 308; + vrLoc = 0; + }; + A1E70E110A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1826; + vrLoc = 0; + }; + A1E70E120A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D3B0A38B5BB007BE3E3 /* client.c */; + name = "client.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 903; + vrLoc = 0; + }; + A1E70E130A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D3C0A38B5BB007BE3E3 /* dllmain.c */; + name = "dllmain.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 298; + vrLoc = 0; + }; + A1E70E140A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D3A0A38B5BB007BE3E3 /* cacheapi.def */; + name = "cacheapi.def: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 847; + vrLoc = 0; + }; + A1E70E150A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D460A38B5BC007BE3E3 /* server.c */; + name = "server.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 756; + vrLoc = 0; + }; + A1E70E160A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2C0A38B5BB007BE3E3 /* main.c */; + name = "main.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 954; + vrLoc = 0; + }; + A1E70E170A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; + name = "serv_ops.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1825; + vrLoc = 0; + }; + A1E70E180A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */; + name = "ccs_ccache.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1861; + vrLoc = 0; + }; + A1E70E1B0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D930A38BB67007BE3E3 /* main.c */; + name = "main.c: 22"; + rLen = 0; + rLoc = 509; + rType = 0; + vrLen = 954; + vrLoc = 0; + }; + A1E70E1E0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D0B0A38B5BB007BE3E3 /* credentials.h */; + name = "credentials.h: 1"; + rLen = 2110; + rLoc = 0; + rType = 0; + vrLen = 1604; + vrLoc = 749; + }; + A1E70E1F0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D130A38B5BB007BE3E3 /* marshall.c */; + name = cci_creds_v5_marshall; + rLen = 21; + rLoc = 6670; + rType = 0; + vrLen = 1513; + vrLoc = 6116; + }; + A1E70E200A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = cci_msg_flatten; + rLen = 15; + rLoc = 7396; + rType = 0; + vrLen = 1003; + vrLoc = 7034; + }; + A1E70E250A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 583"; + rLen = 0; + rLoc = 20525; + rType = 0; + vrLen = 2454; + vrLoc = 18163; + }; + A1E70E260A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D9E0A38BCAD007BE3E3 /* mig.defs */; + name = "ccapi_ipc.defs: 55"; + rLen = 0; + rLoc = 2520; + rType = 0; + vrLen = 1955; + vrLoc = 87; + }; + A1E70E290A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE40A38C6FD007BE3E3 /* kipc_client.c */; + name = "kipc_client.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1544; + vrLoc = 0; + }; + A1E70E2A0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE50A38C6FD007BE3E3 /* kipc_common.c */; + name = "kipc_common.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1496; + vrLoc = 0; + }; + A1E70E2B0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE80A38C6FD007BE3E3 /* notify.defs */; + name = "notify.defs: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1437; + vrLoc = 0; + }; + A1E70E2D0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE60A38C6FD007BE3E3 /* kipc_server.c */; + name = "kipc_server.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1538; + vrLoc = 0; + }; + A1E70E2E0A38C765007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE70A38C6FD007BE3E3 /* kipc_session.c */; + name = "kipc_session.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1461; + vrLoc = 0; + }; + A1E70E380A38C778007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D000A38B5BB007BE3E3 /* cacheapi.c */; + name = "#include "; + rLen = 30; + rLoc = 2170; + rType = 0; + vrLen = 696; + vrLoc = 1821; + }; + A1E70E3D0A38C78C007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D260A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 437; + vrLoc = 0; + }; + A1E70E410A38C78C007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D260A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 437; + vrLoc = 0; + }; + A1E70E430A38C791007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D0F0A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 432; + vrLoc = 0; + }; + A1E70E450A38C791007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D0F0A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 432; + vrLoc = 0; + }; + A1E70E4A0A38C7BE007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D0F0A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 432; + vrLoc = 0; + }; + A1E70E520A38C9FD007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D150A38B5BB007BE3E3 /* NTMakefile */; + name = "NTMakefile: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 308; + vrLoc = 0; + }; + A1E70E530A38C9FD007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1C0A38B5BB007BE3E3 /* datastore.h */; + name = cc_list_type; + rLen = 0; + rLoc = 2301; + rType = 0; + vrLen = 425; + vrLoc = 2113; + }; + A1E70E560A38C9FD007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = cc_list_type; + rLen = 12; + rLoc = 2736; + rType = 0; + vrLen = 728; + vrLoc = 2219; + }; + A1E70E580A38C9FD007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1C0A38B5BB007BE3E3 /* datastore.h */; + name = cc_list_type; + rLen = 0; + rLoc = 2301; + rType = 0; + vrLen = 425; + vrLoc = 2113; + }; + A1E70E6F0A38CA08007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1F0A38B5BB007BE3E3 /* msg.h */; + name = "#include \"generic_lists.h\""; + rLen = 27; + rLoc = 2765; + rType = 0; + vrLen = 755; + vrLoc = 2478; + }; + A1E70E770A38CA55007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D190A38B5BB007BE3E3 /* cc_rpc.h */; + name = "#include \"msg.h\""; + rLen = 18; + rLoc = 2202; + rType = 0; + vrLen = 644; + vrLoc = 1674; + }; + A1E70E7D0A38CA55007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D190A38B5BB007BE3E3 /* cc_rpc.h */; + name = "#include \"msg.h\""; + rLen = 18; + rLoc = 2202; + rType = 0; + vrLen = 644; + vrLoc = 1674; + }; + A1E70E9C0A38CAF1007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 56"; + rLen = 0; + rLoc = 2280; + rType = 0; + vrLen = 463; + vrLoc = 2119; + }; + A1E70EA80A38CB24007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: cc_generic_list_node_t"; + rLen = 0; + rLoc = 2452; + rType = 0; + vrLen = 598; + vrLoc = 2206; + }; + A1E70EAB0A38CB24007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D080A38B5BB007BE3E3 /* context.c */; + name = "code = cci_msg_add_data_blob(request, (void *)name, strlen(name) + 1, &blob_pos);"; + rLen = 86; + rLoc = 14073; + rType = 0; + vrLen = 704; + vrLoc = 13925; + }; + A1E70EB50A38CB4D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D000A38B5BB007BE3E3 /* cacheapi.c */; + name = "strncpy(vendor, string, sizeof(vendor)-1);"; + rLen = 55; + rLoc = 4926; + rType = 0; + vrLen = 780; + vrLoc = 1821; + }; + A1E70EC30A38CC14007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D010A38B5BB007BE3E3 /* ccache.c */; + name = "ccache.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 1115; + vrLoc = 0; + }; + A1E70ECB0A38CC4C007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE40A38C6FD007BE3E3 /* kipc_client.c */; + name = "#include "; + rLen = 34; + rLoc = 1240; + rType = 0; + vrLen = 891; + vrLoc = 724; + }; + A1E70ED70A38CCB6007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE40A38C6FD007BE3E3 /* kipc_client.c */; + name = "#include "; + rLen = 34; + rLoc = 1240; + rType = 0; + vrLen = 1069; + vrLoc = 582; + }; + A1E70EE20A38CCD6007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DB10A38C01E007BE3E3 /* mig_types.h */; + name = "ccapi_ipc.h: 39"; + rLen = 0; + rLoc = 1957; + rType = 0; + vrLen = 892; + vrLoc = 1209; + }; + A1E70EFE0A38CD66007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE10A38C6FD007BE3E3 /* kipc_common.h */; + name = "#include "; + rLen = 36; + rLoc = 1293; + rType = 0; + vrLen = 609; + vrLoc = 1011; + }; + A1E70F0F0A38CE21007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D3B0A38B5BB007BE3E3 /* client.c */; + name = "client.c: 1"; + rLen = 0; + rLoc = 0; + rType = 0; + vrLen = 903; + vrLoc = 0; + }; + A1E70F440A38D252007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DB10A38C01E007BE3E3 /* mig_types.h */; + name = "msg_ipc.h: 48"; + rLen = 0; + rLoc = 2188; + rType = 0; + vrLen = 793; + vrLoc = 1409; + }; + A1E70F450A38D252007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DE10A38C6FD007BE3E3 /* kipc_common.h */; + name = "kipc_common.h: 32"; + rLen = 0; + rLoc = 1293; + rType = 0; + vrLen = 1252; + vrLoc = 450; + }; + A1E70F8B0A38D3B4007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D9E0A38BCAD007BE3E3 /* mig.defs */; + name = "msg_ipc.defs: 43"; + rLen = 0; + rLoc = 2111; + rType = 0; + vrLen = 1149; + vrLoc = 1378; + }; + A1E70F9C0A38D41E007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70DB10A38C01E007BE3E3 /* mig_types.h */; + name = "mig_types.h: 48"; + rLen = 0; + rLoc = 2188; + rType = 0; + vrLen = 1178; + vrLoc = 1024; + }; + A1E70F9D0A38D41E007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D9E0A38BCAD007BE3E3 /* mig.defs */; + name = "mig.defs: 44"; + rLen = 0; + rLoc = 2123; + rType = 0; + vrLen = 1034; + vrLoc = 1439; + }; + A1E70FC60A38D560007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70FC70A38D560007BE3E3 /* migServer.h */; + name = ccapi_server; + rLen = 12; + rLoc = 1268; + rType = 0; + vrLen = 879; + vrLoc = 942; + }; + A1E70FC70A38D560007BE3E3 /* migServer.h */ = { + isa = PBXFileReference; + name = migServer.h; + path = "/Volumes/Ra-Tilt/Users/lxs/Builds/CCAPI.build/Debug/CCacheServer.build/DerivedSources/migServer.h"; + sourceTree = ""; + }; + A1E70FC80A38D560007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D930A38BB67007BE3E3 /* main.c */; + name = "main.c: 23"; + rLen = 0; + rLoc = 495; + rType = 0; + vrLen = 691; + vrLoc = 0; + }; + A1E70FC90A38D560007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1C0A38B5BB007BE3E3 /* datastore.h */; + name = "datastore.h: 55"; + rLen = 0; + rLoc = 2301; + rType = 0; + vrLen = 805; + vrLoc = 2101; + }; + A1E70FCA0A38D560007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 52"; + rLen = 0; + rLoc = 2371; + rType = 0; + vrLen = 757; + vrLoc = 2012; + }; + A1E70FCD0A38D560007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D930A38BB67007BE3E3 /* main.c */; + name = "main.c: 23"; + rLen = 0; + rLoc = 495; + rType = 0; + vrLen = 691; + vrLoc = 0; + }; + A1E70FD80A38D573007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D930A38BB67007BE3E3 /* main.c */; + name = "syslog (LOG_INFO, \"Starting up.\");"; + rLen = 42; + rLoc = 316; + rType = 0; + vrLen = 628; + vrLoc = 21; + }; + A1E70FEE0A38D7C0007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D130A38B5BB007BE3E3 /* marshall.c */; + name = "marshall.c: 48"; + rLen = 0; + rLoc = 2234; + rType = 0; + vrLen = 831; + vrLoc = 1674; + }; + A1E70FEF0A38D7C0007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D010A38B5BB007BE3E3 /* ccache.c */; + name = "ccache.c: 49"; + rLen = 0; + rLoc = 2186; + rType = 0; + vrLen = 432; + vrLoc = 2106; + }; + A1E70FF00A38D7C0007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D080A38B5BB007BE3E3 /* context.c */; + name = "code = cci_msg_retrieve_blob(response, ntohl(response_header->vendor_offset), ntohl(response_header->vendor_length), &string);"; + rLen = 139; + rLoc = 29872; + rType = 0; + vrLen = 757; + vrLoc = 27442; + }; + A1E70FFA0A38D806007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D130A38B5BB007BE3E3 /* marshall.c */; + name = "memcpy(creds->client, flat + header->client.data, length);"; + rLen = 68; + rLoc = 11995; + rType = 0; + vrLen = 1038; + vrLoc = 11543; + }; + A1E70FFC0A38D806007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D020A38B5BB007BE3E3 /* ccache.h */; + name = cc_handle; + rLen = 9; + rLoc = 2339; + rType = 0; + vrLen = 663; + vrLoc = 2042; + }; + A1E70FFF0A38D806007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D020A38B5BB007BE3E3 /* ccache.h */; + name = cc_handle; + rLen = 9; + rLoc = 2339; + rType = 0; + vrLen = 663; + vrLoc = 2042; + }; + A1E710010A38D814007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 617; + vrLoc = 4722; + }; + A1E7100A0A38D888007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 619; + vrLoc = 4720; + }; + A1E7100C0A38D888007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D080A38B5BB007BE3E3 /* context.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 29891; + rType = 0; + vrLen = 1038; + vrLoc = 29282; + }; + A1E7100D0A38D888007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D0C0A38B5BB007BE3E3 /* credentials_iterator.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 6723; + rType = 0; + vrLen = 1080; + vrLoc = 6223; + }; + A1E710110A38D888007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 22827; + rType = 0; + vrLen = 921; + vrLoc = 22183; + }; + A1E710140A38D888007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D0C0A38B5BB007BE3E3 /* credentials_iterator.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 6723; + rType = 0; + vrLen = 1080; + vrLoc = 6223; + }; + A1E7103C0A38DE0B007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1F0A38B5BB007BE3E3 /* msg.h */; + name = "msg.h: 142"; + rLen = 0; + rLoc = 5529; + rType = 0; + vrLen = 1239; + vrLoc = 4630; + }; + A1E710400A38DE0B007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: cci_msg_retrieve_blob"; + rLen = 0; + rLoc = 15353; + rType = 0; + vrLen = 962; + vrLoc = 14947; + }; + A1E710530A39EC0B007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; + name = "serv_ops.c: 322"; + rLen = 0; + rLoc = 12676; + rType = 0; + vrLen = 1049; + vrLoc = 12199; + }; + A1E7105A0A39ED89007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D000A38B5BB007BE3E3 /* cacheapi.c */; + name = "code = cci_msg_retrieve_blob(response, ntohl(response_header->vendor_offset), ntohl(response_header->vendor_length), &string);"; + rLen = 139; + rLoc = 4787; + rType = 0; + vrLen = 1079; + vrLoc = 4176; + }; + A1E7105D0A39ED89007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D000A38B5BB007BE3E3 /* cacheapi.c */; + name = "code = cci_msg_retrieve_blob(response, ntohl(response_header->vendor_offset), ntohl(response_header->vendor_length), &string);"; + rLen = 139; + rLoc = 4787; + rType = 0; + vrLen = 1079; + vrLoc = 4176; + }; + A1E7105E0A39ED89007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "cur_pos = msg->flat;"; + rLen = 25; + rLoc = 7704; + rType = 0; + vrLen = 835; + vrLoc = 7353; + }; + A1E710680A39F102007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; + name = "resp_header->ccache = htonll((cc_handle) ccache);"; + rLen = 54; + rLoc = 23249; + rType = 0; + vrLen = 1200; + vrLoc = 22714; + }; + A1E710840A3A1CFB007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D010A38B5BB007BE3E3 /* ccache.c */; + name = "ccache.c: 378"; + rLen = 0; + rLoc = 11919; + rType = 0; + vrLen = 1092; + vrLoc = 11685; + }; + A1E710860A3A1CFB007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: 585"; + rLen = 0; + rLoc = 15353; + rType = 0; + vrLen = 1129; + vrLoc = 14797; + }; + A1E710870A3A1CFB007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D010A38B5BB007BE3E3 /* ccache.c */; + name = "ccache.c: 378"; + rLen = 0; + rLoc = 11919; + rType = 0; + vrLen = 1092; + vrLoc = 11685; + }; + A1E710890A3A1D04007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */; + name = "ccs_ccache.c: 289"; + rLen = 0; + rLoc = 9783; + rType = 0; + vrLen = 919; + vrLoc = 9327; + }; + A1E7108B0A3A1D04007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */; + name = "ccs_ccache.c: 289"; + rLen = 0; + rLoc = 9783; + rType = 0; + vrLen = 919; + vrLoc = 9327; + }; + A1E7108D0A3A1D06007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */; + name = "ccs_ccache.c: 289"; + rLen = 0; + rLoc = 9783; + rType = 0; + vrLen = 1441; + vrLoc = 9196; + }; + A1E710930A3A1D22007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 36879; + rType = 0; + vrLen = 1393; + vrLoc = 35980; + }; + A1E710940A3A1D22007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1F0A38B5BB007BE3E3 /* msg.h */; + name = "msg.h: 142"; + rLen = 0; + rLoc = 5529; + rType = 0; + vrLen = 1480; + vrLoc = 4457; + }; + A1E710950A3A1D22007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + rLen = 21; + rLoc = 14700; + rType = 0; + }; + A1E710960A3A1D22007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 36879; + rType = 0; + vrLen = 1393; + vrLoc = 35980; + }; + A1E710970A3A1D22007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1F0A38B5BB007BE3E3 /* msg.h */; + name = "msg.h: 142"; + rLen = 0; + rLoc = 5529; + rType = 0; + vrLen = 1480; + vrLoc = 4457; + }; + A1E7109C0A3A1D2B007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 36879; + rType = 0; + vrLen = 1196; + vrLoc = 36344; + }; + A1E7109D0A3A1D2B007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + comments = "error: conflicting types for 'cci_msg_retrieve_blob'"; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + rLen = 1; + rLoc = 570; + rType = 1; + }; + A1E7109F0A3A1DD0007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: 1248"; + rLen = 0; + rLoc = 16800; + rType = 0; + vrLen = 1576; + vrLoc = 14015; + }; + A1E710A00A3A1DD0007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: 1248"; + rLen = 0; + rLoc = 16800; + rType = 0; + vrLen = 1582; + vrLoc = 0; + }; + A1E710A50A3A22E1007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: 623"; + rLen = 0; + rLoc = 16800; + rType = 0; + vrLen = 1674; + vrLoc = 0; + }; + A1E710AB0A3A22F5007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: 623"; + rLen = 0; + rLoc = 16800; + rType = 0; + vrLen = 2012; + vrLoc = 0; + }; + A1E710AC0A3A22F5007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: cci_msg_retrieve_blob"; + rLen = 0; + rLoc = 15346; + rType = 0; + vrLen = 1284; + vrLoc = 15187; + }; + A1E710AD0A3A22F5007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: cci_msg_retrieve_blob"; + rLen = 0; + rLoc = 15346; + rType = 0; + vrLen = 1209; + vrLoc = 15187; + }; + A1E710AF0A3A22FE007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: cci_msg_retrieve_blob"; + rLen = 0; + rLoc = 15346; + rType = 0; + vrLen = 1589; + vrLoc = 14614; + }; + A1E710B30A3A22FF007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = "msg.c: cci_msg_retrieve_blob"; + rLen = 0; + rLoc = 15346; + rType = 0; + vrLen = 1209; + vrLoc = 15187; + }; + A1E710B90A3A23FB007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 15262; + rType = 0; + vrLen = 1209; + vrLoc = 15187; + }; + A1E710BC0A3A2415007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 15262; + rType = 0; + vrLen = 1356; + vrLoc = 15083; + }; + A1E710BD0A3A2415007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 56"; + rLen = 0; + rLoc = 2280; + rType = 0; + vrLen = 873; + vrLoc = 1826; + }; + A1E710BE0A3A2415007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 15262; + rType = 0; + vrLen = 1356; + vrLoc = 15083; + }; + A1E710BF0A3A2415007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 56"; + rLen = 0; + rLoc = 2280; + rType = 0; + vrLen = 863; + vrLoc = 1826; + }; + A1E710C00A3A2415007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 15262; + rType = 0; + vrLen = 1209; + vrLoc = 15187; + }; + A1E710C60A3A2441007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 56"; + rLen = 0; + rLoc = 2280; + rType = 0; + vrLen = 863; + vrLoc = 1826; + }; + A1E710C70A3A2441007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 54"; + rLen = 0; + rLoc = 2452; + rType = 0; + vrLen = 1215; + vrLoc = 1674; + }; + A1E710C80A3A2441007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 56"; + rLen = 0; + rLoc = 2280; + rType = 0; + vrLen = 863; + vrLoc = 1826; + }; + A1E710C90A3A2441007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 58"; + rLen = 0; + rLoc = 2369; + rType = 0; + vrLen = 939; + vrLoc = 1935; + }; + A1E710CA0A3A244D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; + name = cci_msg_retrieve_blob; + rLen = 21; + rLoc = 15262; + rType = 0; + vrLen = 1209; + vrLoc = 15187; + }; + A1E710CB0A3A244D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 58"; + rLen = 0; + rLoc = 2369; + rType = 0; + vrLen = 696; + vrLoc = 2147; + }; + A1E710CC0A3A244D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + comments = "error: CredentialsCache.h: No such file or directory"; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + rLen = 1; + rLoc = 53; + rType = 1; + }; + A1E710CD0A3A244D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 58"; + rLen = 0; + rLoc = 2369; + rType = 0; + vrLen = 696; + vrLoc = 2147; + }; + A1E710CE0A3A244D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "#include \"CredentialsCache.h\""; + rLen = 31; + rLoc = 2221; + rType = 0; + vrLen = 608; + vrLoc = 2043; + }; + A1E710D00A3A2456007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 58"; + rLen = 0; + rLoc = 2369; + rType = 0; + vrLen = 906; + vrLoc = 2012; + }; + A1E710D10A3A2456007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "#include \"CredentialsCache.h\""; + rLen = 31; + rLoc = 2221; + rType = 0; + vrLen = 861; + vrLoc = 1792; + }; + A1E710D20A3A2456007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 822; + vrLoc = 4694; + }; + A1E710D30A3A2456007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "#include \"CredentialsCache.h\""; + rLen = 31; + rLoc = 2221; + rType = 0; + vrLen = 861; + vrLoc = 1792; + }; + A1E710D40A3A2456007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 822; + vrLoc = 4694; + }; + A1E710D70A3A2465007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 802; + vrLoc = 4694; + }; + A1E710D80A3A2465007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "#include \"CredentialsCache.h\""; + rLen = 31; + rLoc = 2221; + rType = 0; + vrLen = 683; + vrLoc = 1899; + }; + A1E710D90A3A2465007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 726; + vrLoc = 4701; + }; + A1E710DB0A3A246E007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 726; + vrLoc = 4701; + }; + A1E710DF0A3A247D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */; + name = "CredentialsCache2.h: 303"; + rLen = 0; + rLoc = 7813; + rType = 0; + vrLen = 786; + vrLoc = 7144; + }; + A1E710E00A3A247D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 802; + vrLoc = 4694; + }; + A1E710E10A3A247D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = cc_handle; + rLen = 9; + rLoc = 5095; + rType = 0; + vrLen = 802; + vrLoc = 4694; + }; + A1E710E20A3A247D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */; + name = "CredentialsCache2.h: 303"; + rLen = 0; + rLoc = 7813; + rType = 0; + vrLen = 786; + vrLoc = 7144; + }; + A1E710E30A3A247D007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 836; + vrLoc = 2610; + }; + A1E710E50A3A248A007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 1007; + vrLoc = 2180; + }; + A1E710E60A3A248A007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 750; + vrLoc = 2696; + }; + A1E710E70A3A24A4007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 750; + vrLoc = 2696; + }; + A1E710E80A3A24A5007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 825; + vrLoc = 2639; + }; + A1E710E90A3A24A5007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 750; + vrLoc = 2696; + }; + A1E710EA0A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 825; + vrLoc = 2639; + }; + A1E710EB0A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */; + name = "CredentialsCache2.h: 303"; + rLen = 0; + rLoc = 7813; + rType = 0; + vrLen = 1103; + vrLoc = 1564; + }; + A1E710EC0A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 58"; + rLen = 0; + rLoc = 2369; + rType = 0; + vrLen = 906; + vrLoc = 2012; + }; + A1E710ED0A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 825; + vrLoc = 2639; + }; + A1E710EE0A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */; + name = "CredentialsCache2.h: 303"; + rLen = 0; + rLoc = 7813; + rType = 0; + vrLen = 1103; + vrLoc = 1564; + }; + A1E710EF0A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */; + name = "generic_lists.h: 58"; + rLen = 0; + rLoc = 2369; + rType = 0; + vrLen = 906; + vrLoc = 2012; + }; + A1E710F00A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 56"; + rLen = 0; + rLoc = 2280; + rType = 0; + vrLen = 842; + vrLoc = 1792; + }; + A1E710F10A3A2521007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 750; + vrLoc = 2696; + }; + A1E710F40A3A253F007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; + name = "generic_lists.c: 57"; + rLen = 0; + rLoc = 2282; + rType = 0; + vrLen = 861; + vrLoc = 1792; + }; + A1E710F50A3A253F007BE3E3 /* PBXTextBookmark */ = { + isa = PBXTextBookmark; + fRef = A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */; + name = "CredentialsCache.h: 67"; + rLen = 0; + rLoc = 2631; + rType = 0; + vrLen = 750; + vrLoc = 2696; + }; + D2AAC045055464E500DB518D /* CCAPI */ = { + activeExec = 0; + }; +} diff --git a/src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.perspective b/src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.perspective new file mode 100644 index 0000000000..198370765b --- /dev/null +++ b/src/lib/ccapi/mac/CCAPI.xcodeproj/lxs.perspective @@ -0,0 +1,1567 @@ + + + + + ActivePerspectiveName + Project + AllowedModules + + + BundleLoadPath + + MaxInstances + n + Module + PBXSmartGroupTreeModule + Name + Groups and Files Outline View + + + BundleLoadPath + + MaxInstances + n + Module + PBXNavigatorGroup + Name + Editor + + + BundleLoadPath + + MaxInstances + n + Module + XCTaskListModule + Name + Task List + + + BundleLoadPath + + MaxInstances + n + Module + XCDetailModule + Name + File and Smart Group Detail Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXBuildResultsModule + Name + Detailed Build Results Viewer + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXProjectFindModule + Name + Project Batch Find Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXRunSessionModule + Name + Run Log + + + BundleLoadPath + + MaxInstances + n + Module + PBXBookmarksModule + Name + Bookmarks Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXClassBrowserModule + Name + Class Browser + + + BundleLoadPath + + MaxInstances + n + Module + PBXCVSModule + Name + Source Code Control Tool + + + BundleLoadPath + + MaxInstances + n + Module + PBXDebugBreakpointsModule + Name + Debug Breakpoints Tool + + + BundleLoadPath + + MaxInstances + n + Module + XCDockableInspector + Name + Inspector + + + BundleLoadPath + + MaxInstances + n + Module + PBXOpenQuicklyModule + Name + Open Quickly Tool + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugSessionModule + Name + Debugger + + + BundleLoadPath + + MaxInstances + 1 + Module + PBXDebugCLIModule + Name + Debug Console + + + Description + AIODescriptionKey + DockingSystemVisible + + Extension + perspective + FavBarConfig + + PBXProjectModuleGUID + A1E70E750A38CA08007BE3E3 + XCBarModuleItemNames + + XCBarModuleItems + + + FirstTimeWindowDisplayed + + Identifier + com.apple.perspectives.project.default + MajorVersion + 33 + MinorVersion + 0 + Name + All-In-One + Notifications + + + XCObserverAutoDisconnectKey + + XCObserverDefintionKey + + XCObserverFactoryKey + XCPerspectivesSpecificationIdentifier + XCObserverGUIDKey + XCObserverProjectIdentifier + XCObserverNotificationKey + PBXStatusBuildStateMessageNotification + XCObserverTargetKey + XCMainBuildResultsModuleGUID + XCObserverTriggerKey + awakenModuleWithObserver: + XCObserverValidationKey + + + + OpenEditors + + PerspectiveWidths + + 1340 + 1340 + 1340 + + Perspectives + + + ChosenToolbarItems + + XCToolbarPerspectiveControl + NSToolbarSeparatorItem + active-target-popup + action + NSToolbarFlexibleSpaceItem + buildOrClean + build-and-runOrDebug + com.apple.ide.PBXToolbarStopButton + get-info + toggle-editor + NSToolbarFlexibleSpaceItem + com.apple.pbx.toolbar.searchfield + + ControllerClassBaseName + + IconName + WindowOfProject + Identifier + perspective.project + IsVertical + + Layout + + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C37FBAC04509CD000000102 + 1C37FAAC04509CD000000102 + 1C08E77C0454961000C914BD + 1C37FABC05509CD000000102 + 1C37FABC05539CD112110102 + E2644B35053B69B200211256 + 1C37FABC04509CD000100104 + 1CC0EA4004350EF90044410B + 1CC0EA4004350EF90041110B + 1C77FABC04509CD000000102 + + PBXProjectModuleGUID + 1CA23ED40692098700951B8B + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 268 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 08FB7794FE84155DC02AAC07 + A1E70CFF0A38B5BB007BE3E3 + A1E70D110A38B5BB007BE3E3 + A1E70D7E0A38BAC5007BE3E3 + A1E70D180A38B5BB007BE3E3 + A1E70D270A38B5BB007BE3E3 + A1E70D2B0A38B5BB007BE3E3 + A1E70D390A38B5BB007BE3E3 + 1C37FBAC04509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 24 + 19 + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {268, 841}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + + GeometryConfiguration + + Frame + {{0, 0}, {285, 859}} + GroupTreeTableConfiguration + + MainColumn + 268 + + RubberWindowFrame + 170 278 1340 900 0 0 1920 1178 + + Module + PBXSmartGroupTreeModule + Proportion + 285pt + + + Dock + + + BecomeActive + + ContentConfiguration + + PBXProjectModuleGUID + A1E70DF50A38C765007BE3E3 + PBXProjectModuleLabel + generic_lists.c + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + A1E70DF60A38C765007BE3E3 + PBXProjectModuleLabel + generic_lists.c + _historyCapacity + 0 + bookmark + A1E710F40A3A253F007BE3E3 + history + + A1E70DF90A38C765007BE3E3 + A1E70DFA0A38C765007BE3E3 + A1E70DFB0A38C765007BE3E3 + A1E70E010A38C765007BE3E3 + A1E70E020A38C765007BE3E3 + A1E70E090A38C765007BE3E3 + A1E70E0A0A38C765007BE3E3 + A1E70E0B0A38C765007BE3E3 + A1E70E0C0A38C765007BE3E3 + A1E70E3D0A38C78C007BE3E3 + A1E70E4A0A38C7BE007BE3E3 + A1E70E520A38C9FD007BE3E3 + A1E70E530A38C9FD007BE3E3 + A1E70E770A38CA55007BE3E3 + A1E70EB50A38CB4D007BE3E3 + A1E70ED70A38CCB6007BE3E3 + A1E70EFE0A38CD66007BE3E3 + A1E70F0F0A38CE21007BE3E3 + A1E70F9C0A38D41E007BE3E3 + A1E70F9D0A38D41E007BE3E3 + A1E70FC60A38D560007BE3E3 + A1E70FD80A38D573007BE3E3 + A1E70FFA0A38D806007BE3E3 + A1E70FFC0A38D806007BE3E3 + A1E7100C0A38D888007BE3E3 + A1E7100D0A38D888007BE3E3 + A1E710840A3A1CFB007BE3E3 + A1E7108D0A3A1D06007BE3E3 + A1E710930A3A1D22007BE3E3 + A1E710940A3A1D22007BE3E3 + A1E710BC0A3A2415007BE3E3 + A1E710EA0A3A2521007BE3E3 + A1E710EB0A3A2521007BE3E3 + A1E710EC0A3A2521007BE3E3 + A1E710D10A3A2456007BE3E3 + + prevStack + + A1E70E100A38C765007BE3E3 + A1E70E110A38C765007BE3E3 + A1E70E120A38C765007BE3E3 + A1E70E130A38C765007BE3E3 + A1E70E140A38C765007BE3E3 + A1E70E150A38C765007BE3E3 + A1E70E160A38C765007BE3E3 + A1E70E180A38C765007BE3E3 + A1E70E1B0A38C765007BE3E3 + A1E70E1E0A38C765007BE3E3 + A1E70E1F0A38C765007BE3E3 + A1E70E200A38C765007BE3E3 + A1E70E250A38C765007BE3E3 + A1E70E260A38C765007BE3E3 + A1E70E290A38C765007BE3E3 + A1E70E2A0A38C765007BE3E3 + A1E70E2B0A38C765007BE3E3 + A1E70E2D0A38C765007BE3E3 + A1E70E2E0A38C765007BE3E3 + A1E70E380A38C778007BE3E3 + A1E70E410A38C78C007BE3E3 + A1E70E450A38C791007BE3E3 + A1E70E560A38C9FD007BE3E3 + A1E70E580A38C9FD007BE3E3 + A1E70E6F0A38CA08007BE3E3 + A1E70E7D0A38CA55007BE3E3 + A1E70EAB0A38CB24007BE3E3 + A1E70EC30A38CC14007BE3E3 + A1E70EE20A38CCD6007BE3E3 + A1E70FFF0A38D806007BE3E3 + A1E710110A38D888007BE3E3 + A1E710140A38D888007BE3E3 + A1E710BE0A3A2415007BE3E3 + A1E710C80A3A2441007BE3E3 + A1E710D30A3A2456007BE3E3 + A1E710E10A3A247D007BE3E3 + A1E710E20A3A247D007BE3E3 + A1E710ED0A3A2521007BE3E3 + A1E710EE0A3A2521007BE3E3 + A1E710EF0A3A2521007BE3E3 + + + SplitCount + 1 + + StatusBarVisibility + + XCSharingToken + com.apple.Xcode.CommonNavigatorGroupSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {1050, 553}} + RubberWindowFrame + 170 278 1340 900 0 0 1920 1178 + + Module + PBXNavigatorGroup + Proportion + 553pt + + + Proportion + 301pt + Tabs + + + ContentConfiguration + + PBXProjectModuleGUID + 1CA23EDF0692099D00951B8B + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{10, 27}, {1050, 274}} + RubberWindowFrame + 170 278 1340 900 0 0 1920 1178 + + Module + XCDetailModule + + + ContentConfiguration + + PBXProjectModuleGUID + 1CA23EE00692099D00951B8B + PBXProjectModuleLabel + Project Find + + GeometryConfiguration + + Frame + {{10, 27}, {1050, 274}} + + Module + PBXProjectFindModule + + + ContentConfiguration + + PBXProjectModuleGUID + 1CA23EE10692099D00951B8B + PBXProjectModuleLabel + SCM Results + + GeometryConfiguration + + Frame + {{10, 31}, {603, 297}} + + Module + PBXCVSModule + + + + + Proportion + 1050pt + + + Name + Project + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + XCModuleDock + PBXNavigatorGroup + XCDockableTabModule + XCDetailModule + PBXProjectFindModule + PBXCVSModule + + TableOfContents + + A1E710B00A3A22FE007BE3E3 + 1CA23ED40692098700951B8B + A1E710B10A3A22FE007BE3E3 + A1E70DF50A38C765007BE3E3 + A1E710B20A3A22FE007BE3E3 + 1CA23EDF0692099D00951B8B + 1CA23EE00692099D00951B8B + 1CA23EE10692099D00951B8B + + ToolbarConfiguration + xcode.toolbar.config.default + + + ChosenToolbarItems + + XCToolbarPerspectiveControl + NSToolbarSeparatorItem + active-target-popup + active-executable-popup + active-buildstyle-popup + NSToolbarFlexibleSpaceItem + build + clean + NSToolbarSeparatorItem + run + debug + + ControllerClassBaseName + + IconName + BuildTabIcon + Identifier + perspective.build + IsVertical + + Layout + + + ContentConfiguration + + PBXBottomSmartGroupGIDs + + PBXProjectModuleGUID + 1CA23EE50692099D00951B8B + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + yes + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 184 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {184, 841}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + + + GeometryConfiguration + + Frame + {{0, 0}, {201, 859}} + GroupTreeTableConfiguration + + MainColumn + 184 + + + Module + PBXSmartGroupTreeModule + Proportion + 201pt + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + A1E70DF50A38C765007BE3E3 + PBXProjectModuleLabel + CredentialsCache.h + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + A1E70DF60A38C765007BE3E3 + PBXProjectModuleLabel + CredentialsCache.h + _historyCapacity + 0 + bookmark + A1E710F50A3A253F007BE3E3 + history + + A1E70DF70A38C765007BE3E3 + A1E70DF80A38C765007BE3E3 + A1E70DF90A38C765007BE3E3 + A1E70DFA0A38C765007BE3E3 + A1E70DFB0A38C765007BE3E3 + A1E70E010A38C765007BE3E3 + A1E70E020A38C765007BE3E3 + A1E70E060A38C765007BE3E3 + A1E70E090A38C765007BE3E3 + A1E70E0A0A38C765007BE3E3 + A1E70E0B0A38C765007BE3E3 + A1E70E0C0A38C765007BE3E3 + A1E70E3D0A38C78C007BE3E3 + A1E70E430A38C791007BE3E3 + A1E70E770A38CA55007BE3E3 + A1E70ECB0A38CC4C007BE3E3 + A1E70F440A38D252007BE3E3 + A1E70F450A38D252007BE3E3 + A1E70F8B0A38D3B4007BE3E3 + A1E70FC60A38D560007BE3E3 + A1E70FC80A38D560007BE3E3 + A1E70FC90A38D560007BE3E3 + A1E70FEE0A38D7C0007BE3E3 + A1E70FEF0A38D7C0007BE3E3 + A1E70FF00A38D7C0007BE3E3 + A1E70FFC0A38D806007BE3E3 + A1E7100D0A38D888007BE3E3 + A1E7103C0A38DE0B007BE3E3 + A1E7105A0A39ED89007BE3E3 + A1E710890A3A1D04007BE3E3 + A1E7109C0A3A1D2B007BE3E3 + A1E710CA0A3A244D007BE3E3 + A1E710CB0A3A244D007BE3E3 + A1E710D80A3A2465007BE3E3 + A1E710E30A3A247D007BE3E3 + + prevStack + + A1E70E100A38C765007BE3E3 + A1E70E110A38C765007BE3E3 + A1E70E120A38C765007BE3E3 + A1E70E130A38C765007BE3E3 + A1E70E140A38C765007BE3E3 + A1E70E150A38C765007BE3E3 + A1E70E160A38C765007BE3E3 + A1E70E170A38C765007BE3E3 + A1E70E180A38C765007BE3E3 + A1E70E1E0A38C765007BE3E3 + A1E70E1F0A38C765007BE3E3 + A1E70E250A38C765007BE3E3 + A1E70E260A38C765007BE3E3 + A1E70E290A38C765007BE3E3 + A1E70E2A0A38C765007BE3E3 + A1E70E2B0A38C765007BE3E3 + A1E70E2D0A38C765007BE3E3 + A1E70E2E0A38C765007BE3E3 + A1E70E380A38C778007BE3E3 + A1E70E410A38C78C007BE3E3 + A1E70E450A38C791007BE3E3 + A1E70E560A38C9FD007BE3E3 + A1E70E580A38C9FD007BE3E3 + A1E70E7D0A38CA55007BE3E3 + A1E70EAB0A38CB24007BE3E3 + A1E70EC30A38CC14007BE3E3 + A1E70EE20A38CCD6007BE3E3 + A1E70FCD0A38D560007BE3E3 + A1E70FFF0A38D806007BE3E3 + A1E710140A38D888007BE3E3 + A1E710400A38DE0B007BE3E3 + A1E70E6F0A38CA08007BE3E3 + A1E710CD0A3A244D007BE3E3 + A1E710E20A3A247D007BE3E3 + + + SplitCount + 1 + + StatusBarVisibility + + XCSharingToken + com.apple.Xcode.CommonNavigatorGroupSharingToken + + GeometryConfiguration + + Frame + {{0, 0}, {1134, 480}} + + Module + PBXNavigatorGroup + Proportion + 480pt + + + Proportion + 374pt + Tabs + + + ContentConfiguration + + PBXProjectModuleGUID + XCMainBuildResultsModuleGUID + PBXProjectModuleLabel + Build + XCBuildResultsTrigger_Collapse + 1021 + XCBuildResultsTrigger_Open + 1010 + + GeometryConfiguration + + Frame + {{10, 27}, {1134, 347}} + + Module + PBXBuildResultsModule + + + ContentConfiguration + + LauncherConfigVersion + 3 + PBXProjectModuleGUID + 1CA23EE80692099D00951B8B + PBXProjectModuleLabel + Run + Runner + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {365, 167}} + {{0, 176}, {365, 267}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {405, 443}} + {{414, 0}, {514, 443}} + + + + + GeometryConfiguration + + Frame + {{0, 0}, {0, 0}} + + Module + PBXRunSessionModule + + + + + Proportion + 1134pt + + + Name + Build + ServiceClasses + + XCModuleDock + PBXSmartGroupTreeModule + XCModuleDock + PBXNavigatorGroup + XCDockableTabModule + PBXBuildResultsModule + PBXRunSessionModule + XCConsole + + TableOfContents + + A1E710B40A3A22FF007BE3E3 + 1CA23EE50692099D00951B8B + A1E710B50A3A22FF007BE3E3 + A1E70DF50A38C765007BE3E3 + A1E710B60A3A22FF007BE3E3 + XCMainBuildResultsModuleGUID + 1CA23EE80692099D00951B8B + A1E710B70A3A22FF007BE3E3 + + ToolbarConfiguration + xcode.toolbar.config.buildAndRun + + + ChosenToolbarItems + + XCToolbarPerspectiveControl + NSToolbarSeparatorItem + build-and-debug + debug + NSToolbarFlexibleSpaceItem + debugger-fix-and-continue + debugger-restart-executable + debugger-pause + debugger-continue + debugger-step-over + debugger-step-into + debugger-step-out + debugger-step-instruction + NSToolbarFlexibleSpaceItem + + ControllerClassBaseName + PBXDebugSessionModule + IconName + DebugTabIcon + Identifier + perspective.debug + IsVertical + 1 + Layout + + + ContentConfiguration + + PBXProjectModuleGUID + 1CCC7628064C1048000F2A68 + PBXProjectModuleLabel + Debugger Console + + GeometryConfiguration + + Frame + {{0, 0}, {810, 0}} + + Module + PBXDebugCLIModule + Proportion + 0% + + + ContentConfiguration + + Debugger + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {395, 213}} + {{395, 0}, {415, 213}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {810, 213}} + {{0, 213}, {810, 225}} + + + + LauncherConfigVersion + 8 + PBXProjectModuleGUID + 1CCC7629064C1048000F2A68 + PBXProjectModuleLabel + Debug + + GeometryConfiguration + + DebugConsoleDrawerSize + {100, 120} + DebugConsoleVisible + None + DebugConsoleWindowFrame + {{200, 200}, {500, 300}} + DebugSTDIOWindowFrame + {{200, 200}, {500, 300}} + Frame + {{0, 7}, {810, 438}} + + Module + PBXDebugSessionModule + Proportion + 443pt + + + Name + Debug + ServiceClasses + + XCModuleDock + XCModuleDock + PBXDebugCLIModule + PBXDebugSessionModule + XCConsole + + TableOfContents + + 1CC8E6A5069209BD00BB180A + 1CC8E6A6069209BD00BB180A + 1CCC7628064C1048000F2A68 + 1CCC7629064C1048000F2A68 + 1CC8E6A7069209BD00BB180A + + ToolbarConfiguration + xcode.toolbar.config.debug + + + PerspectivesBarVisible + + ShelfIsVisible + + SourceDescription + file at '/System/Library/PrivateFrameworks/DevToolsInterface.framework/Versions/A/Resources/XCPerspectivesSpecification.xcperspec' + StatusbarIsVisible + + TimeStamp + 171582783.00723499 + ToolbarDisplayMode + 1 + ToolbarIsVisible + + ToolbarSizeMode + 1 + Type + Perspectives + UpdateMessage + + WindowJustification + 5 + WindowOrderList + + /Volumes/Ra-Tilt/Users/lxs/KfM/CCAPI/src/lib/ccapi/mac/CCAPI.xcodeproj + + WindowString + 170 278 1340 900 0 0 1920 1178 + WindowTools + + + Identifier + windowTool.find + Layout + + + Dock + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1CDD528C0622207200134675 + PBXProjectModuleLabel + <No Editor> + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1CD0528D0623707200166675 + + SplitCount + 1 + + StatusBarVisibility + 1 + + GeometryConfiguration + + Frame + {{0, 0}, {781, 167}} + RubberWindowFrame + 62 385 781 470 0 0 1440 878 + + Module + PBXNavigatorGroup + Proportion + 781pt + + + Proportion + 50% + + + BecomeActive + 1 + ContentConfiguration + + PBXProjectModuleGUID + 1CD0528E0623707200166675 + PBXProjectModuleLabel + Project Find + + GeometryConfiguration + + Frame + {{8, 0}, {773, 254}} + RubberWindowFrame + 62 385 781 470 0 0 1440 878 + + Module + PBXProjectFindModule + Proportion + 50% + + + Proportion + 428pt + + + Name + Project Find + ServiceClasses + + PBXProjectFindModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C530D57069F1CE1000CFCEE + 1C530D58069F1CE1000CFCEE + 1C530D59069F1CE1000CFCEE + 1CDD528C0622207200134675 + 1C530D5A069F1CE1000CFCEE + 1CE0B1FE06471DED0097A5F4 + 1CD0528E0623707200166675 + + WindowString + 62 385 781 470 0 0 1440 878 + WindowToolGUID + 1C530D57069F1CE1000CFCEE + WindowToolIsVisible + 0 + + + Identifier + windowTool.run + Layout + + + Dock + + + ContentConfiguration + + LauncherConfigVersion + 3 + PBXProjectModuleGUID + 1CD0528B0623707200166675 + PBXProjectModuleLabel + Run - cocoapp112 - cocoapp112 + Runner + + HorizontalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {365, 167}} + {{0, 176}, {365, 267}} + + + VerticalSplitView + + _collapsingFrameDimension + 0.0 + _indexOfCollapsedView + 0 + _percentageOfCollapsedView + 0.0 + isCollapsed + yes + sizes + + {{0, 0}, {405, 443}} + {{414, 0}, {514, 443}} + + + + + GeometryConfiguration + + Frame + {{0, 0}, {456, 192}} + RubberWindowFrame + 741 130 456 234 0 0 1280 1002 + + Module + PBXRunSessionModule + Proportion + 192pt + + + Proportion + 192pt + + + Name + Run Log + ServiceClasses + + PBXRunSessionModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C78EAAF065D492600B07095 + 1C78EAB0065D492600B07095 + 1CD0528B0623707200166675 + 1C78EAB1065D492600B07095 + + ToolbarConfiguration + xcode.toolbar.config.run + WindowString + 741 130 456 234 0 0 1280 1002 + + + Identifier + windowTool.scm + Layout + + + Dock + + + ContentConfiguration + + PBXProjectModuleGUID + 1C78EAB2065D492600B07095 + PBXProjectModuleLabel + <No Editor> + PBXSplitModuleInNavigatorKey + + Split0 + + PBXProjectModuleGUID + 1C78EAB3065D492600B07095 + + SplitCount + 1 + + StatusBarVisibility + 1 + + GeometryConfiguration + + Frame + {{0, 0}, {452, 0}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + + Module + PBXNavigatorGroup + Proportion + 0pt + + + BecomeActive + 1 + ContentConfiguration + + PBXProjectModuleGUID + 1CD052920623707200166675 + PBXProjectModuleLabel + SCM + + GeometryConfiguration + + ConsoleFrame + {{0, 259}, {452, 0}} + Frame + {{0, 7}, {452, 259}} + RubberWindowFrame + 743 379 452 308 0 0 1280 1002 + TableConfiguration + + Status + 30 + FileName + 199 + Path + 197.09500122070312 + + TableFrame + {{0, 0}, {452, 250}} + + Module + PBXCVSModule + Proportion + 262pt + + + Proportion + 266pt + + + Name + SCM + ServiceClasses + + PBXCVSModule + + StatusbarIsVisible + 1 + TableOfContents + + 1C78EAB4065D492600B07095 + 1C78EAB5065D492600B07095 + 1C78EAB2065D492600B07095 + 1CD052920623707200166675 + + ToolbarConfiguration + xcode.toolbar.config.scm + WindowString + 743 379 452 308 0 0 1280 1002 + + + Identifier + windowTool.breakpoints + IsVertical + 0 + Layout + + + Dock + + + BecomeActive + 1 + ContentConfiguration + + PBXBottomSmartGroupGIDs + + 1C77FABC04509CD000000102 + + PBXProjectModuleGUID + 1CE0B1FE06471DED0097A5F4 + PBXProjectModuleLabel + Files + PBXProjectStructureProvided + no + PBXSmartGroupTreeModuleColumnData + + PBXSmartGroupTreeModuleColumnWidthsKey + + 168 + + PBXSmartGroupTreeModuleColumnsKey_v4 + + MainColumn + + + PBXSmartGroupTreeModuleOutlineStateKey_v7 + + PBXSmartGroupTreeModuleOutlineStateExpansionKey + + 1C77FABC04509CD000000102 + + PBXSmartGroupTreeModuleOutlineStateSelectionKey + + + 0 + + + PBXSmartGroupTreeModuleOutlineStateVisibleRectKey + {{0, 0}, {168, 350}} + + PBXTopSmartGroupGIDs + + XCIncludePerspectivesSwitch + 0 + + GeometryConfiguration + + Frame + {{0, 0}, {185, 368}} + GroupTreeTableConfiguration + + MainColumn + 168 + + RubberWindowFrame + 315 424 744 409 0 0 1440 878 + + Module + PBXSmartGroupTreeModule + Proportion + 185pt + + + ContentConfiguration + + PBXProjectModuleGUID + 1CA1AED706398EBD00589147 + PBXProjectModuleLabel + Detail + + GeometryConfiguration + + Frame + {{190, 0}, {554, 368}} + RubberWindowFrame + 315 424 744 409 0 0 1440 878 + + Module + XCDetailModule + Proportion + 554pt + + + Proportion + 368pt + + + MajorVersion + 2 + MinorVersion + 0 + Name + Breakpoints + ServiceClasses + + PBXSmartGroupTreeModule + XCDetailModule + + StatusbarIsVisible + 1 + TableOfContents + + 1CDDB66807F98D9800BB5817 + 1CDDB66907F98D9800BB5817 + 1CE0B1FE06471DED0097A5F4 + 1CA1AED706398EBD00589147 + + ToolbarConfiguration + xcode.toolbar.config.breakpoints + WindowString + 315 424 744 409 0 0 1440 878 + WindowToolGUID + 1CDDB66807F98D9800BB5817 + WindowToolIsVisible + 1 + + + Identifier + windowTool.debugAnimator + Layout + + + Dock + + + Module + PBXNavigatorGroup + Proportion + 100% + + + Proportion + 100% + + + Name + Debug Visualizer + ServiceClasses + + PBXNavigatorGroup + + StatusbarIsVisible + 1 + ToolbarConfiguration + xcode.toolbar.config.debugAnimator + WindowString + 100 100 700 500 0 0 1280 1002 + + + Identifier + windowTool.bookmarks + Layout + + + Dock + + + Module + PBXBookmarksModule + Proportion + 166pt + + + Proportion + 166pt + + + Name + Bookmarks + ServiceClasses + + PBXBookmarksModule + + StatusbarIsVisible + 0 + WindowString + 538 42 401 187 0 0 1280 1002 + + + Identifier + windowTool.classBrowser + Layout + + + Dock + + + BecomeActive + 1 + ContentConfiguration + + OptionsSetName + Hierarchy, all classes + PBXProjectModuleGUID + 1CA6456E063B45B4001379D8 + PBXProjectModuleLabel + Class Browser - NSObject + + GeometryConfiguration + + ClassesFrame + {{0, 0}, {369, 96}} + ClassesTreeTableConfiguration + + PBXClassNameColumnIdentifier + 208 + PBXClassBookColumnIdentifier + 22 + + Frame + {{0, 0}, {616, 353}} + MembersFrame + {{0, 105}, {369, 395}} + MembersTreeTableConfiguration + + PBXMemberTypeIconColumnIdentifier + 22 + PBXMemberNameColumnIdentifier + 216 + PBXMemberTypeColumnIdentifier + 94 + PBXMemberBookColumnIdentifier + 22 + + PBXModuleWindowStatusBarHidden2 + 1 + RubberWindowFrame + 597 125 616 374 0 0 1280 1002 + + Module + PBXClassBrowserModule + Proportion + 354pt + + + Proportion + 354pt + + + Name + Class Browser + ServiceClasses + + PBXClassBrowserModule + + StatusbarIsVisible + 0 + TableOfContents + + 1C78EABA065D492600B07095 + 1C78EABB065D492600B07095 + 1CA6456E063B45B4001379D8 + + ToolbarConfiguration + xcode.toolbar.config.classbrowser + WindowString + 597 125 616 374 0 0 1280 1002 + + + + diff --git a/src/lib/ccapi/mac/CCAPI.xcodeproj/project.pbxproj b/src/lib/ccapi/mac/CCAPI.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..38a73b4c96 --- /dev/null +++ b/src/lib/ccapi/mac/CCAPI.xcodeproj/project.pbxproj @@ -0,0 +1,599 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 42; + objects = { + +/* Begin PBXBuildFile section */ + A1E70D480A38B5D5007BE3E3 /* cacheapi.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D000A38B5BB007BE3E3 /* cacheapi.c */; }; + A1E70D490A38B5D5007BE3E3 /* ccache.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D010A38B5BB007BE3E3 /* ccache.c */; }; + A1E70D4A0A38B5D5007BE3E3 /* ccache_iterator.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D030A38B5BB007BE3E3 /* ccache_iterator.c */; }; + A1E70D4B0A38B5D5007BE3E3 /* ccapiv2.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D050A38B5BB007BE3E3 /* ccapiv2.c */; }; + A1E70D4C0A38B5D5007BE3E3 /* ccstring.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D060A38B5BB007BE3E3 /* ccstring.c */; }; + A1E70D4D0A38B5D5007BE3E3 /* context.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D080A38B5BB007BE3E3 /* context.c */; }; + A1E70D4E0A38B5D5007BE3E3 /* credentials.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D0A0A38B5BB007BE3E3 /* credentials.c */; }; + A1E70D4F0A38B5D5007BE3E3 /* credentials_iterator.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D0C0A38B5BB007BE3E3 /* credentials_iterator.c */; }; + A1E70D510A38B60C007BE3E3 /* generic_lists.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; }; + A1E70D520A38B60C007BE3E3 /* marshall.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D130A38B5BB007BE3E3 /* marshall.c */; }; + A1E70D530A38B60C007BE3E3 /* msg.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; }; + A1E70D890A38BB47007BE3E3 /* ccs_ccache.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */; }; + A1E70D8A0A38BB47007BE3E3 /* ccs_context.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D290A38B5BB007BE3E3 /* ccs_context.c */; }; + A1E70D8B0A38BB47007BE3E3 /* ccs_lists.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D2A0A38B5BB007BE3E3 /* ccs_lists.c */; }; + A1E70D8C0A38BB47007BE3E3 /* rpc_auth.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D2E0A38B5BB007BE3E3 /* rpc_auth.c */; }; + A1E70D8D0A38BB47007BE3E3 /* serv_ops.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */; }; + A1E70D8E0A38BB4F007BE3E3 /* generic_lists.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D120A38B5BB007BE3E3 /* generic_lists.c */; }; + A1E70D8F0A38BB4F007BE3E3 /* marshall.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D130A38B5BB007BE3E3 /* marshall.c */; }; + A1E70D900A38BB4F007BE3E3 /* msg.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D140A38B5BB007BE3E3 /* msg.c */; }; + A1E70D9B0A38BBE2007BE3E3 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D930A38BB67007BE3E3 /* main.c */; }; + A1E70D9F0A38BCAD007BE3E3 /* mig.defs in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D9E0A38BCAD007BE3E3 /* mig.defs */; }; + A1E70DA00A38BCAD007BE3E3 /* mig.defs in Sources */ = {isa = PBXBuildFile; fileRef = A1E70D9E0A38BCAD007BE3E3 /* mig.defs */; settings = {ATTRIBUTES = (Server, ); }; }; + A1E70DEA0A38C710007BE3E3 /* kipc_client.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70DE40A38C6FD007BE3E3 /* kipc_client.c */; }; + A1E70DEB0A38C710007BE3E3 /* kipc_common.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70DE50A38C6FD007BE3E3 /* kipc_common.c */; }; + A1E70DEC0A38C710007BE3E3 /* kipc_session.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70DE70A38C6FD007BE3E3 /* kipc_session.c */; }; + A1E70DED0A38C71D007BE3E3 /* kipc_common.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70DE50A38C6FD007BE3E3 /* kipc_common.c */; }; + A1E70DEE0A38C71D007BE3E3 /* kipc_server.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70DE60A38C6FD007BE3E3 /* kipc_server.c */; }; + A1E70DEF0A38C71D007BE3E3 /* kipc_session.c in Sources */ = {isa = PBXBuildFile; fileRef = A1E70DE70A38C6FD007BE3E3 /* kipc_session.c */; }; + A1E70DF00A38C71D007BE3E3 /* notify.defs in Sources */ = {isa = PBXBuildFile; fileRef = A1E70DE80A38C6FD007BE3E3 /* notify.defs */; settings = {ATTRIBUTES = (Server, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + A1E70D000A38B5BB007BE3E3 /* cacheapi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cacheapi.c; sourceTree = ""; }; + A1E70D010A38B5BB007BE3E3 /* ccache.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccache.c; sourceTree = ""; }; + A1E70D020A38B5BB007BE3E3 /* ccache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccache.h; sourceTree = ""; }; + A1E70D030A38B5BB007BE3E3 /* ccache_iterator.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccache_iterator.c; sourceTree = ""; }; + A1E70D040A38B5BB007BE3E3 /* ccache_iterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccache_iterator.h; sourceTree = ""; }; + A1E70D050A38B5BB007BE3E3 /* ccapiv2.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccapiv2.c; sourceTree = ""; }; + A1E70D060A38B5BB007BE3E3 /* ccstring.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccstring.c; sourceTree = ""; }; + A1E70D070A38B5BB007BE3E3 /* ccstring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ccstring.h; sourceTree = ""; }; + A1E70D080A38B5BB007BE3E3 /* context.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = context.c; sourceTree = ""; }; + A1E70D090A38B5BB007BE3E3 /* context.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = context.h; sourceTree = ""; }; + A1E70D0A0A38B5BB007BE3E3 /* credentials.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = credentials.c; sourceTree = ""; }; + A1E70D0B0A38B5BB007BE3E3 /* credentials.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = credentials.h; sourceTree = ""; }; + A1E70D0C0A38B5BB007BE3E3 /* credentials_iterator.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = credentials_iterator.c; sourceTree = ""; }; + A1E70D0D0A38B5BB007BE3E3 /* credentials_iterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = credentials_iterator.h; sourceTree = ""; }; + A1E70D0F0A38B5BB007BE3E3 /* NTMakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NTMakefile; sourceTree = ""; }; + A1E70D120A38B5BB007BE3E3 /* generic_lists.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = generic_lists.c; sourceTree = ""; }; + A1E70D130A38B5BB007BE3E3 /* marshall.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = marshall.c; sourceTree = ""; }; + A1E70D140A38B5BB007BE3E3 /* msg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = msg.c; sourceTree = ""; }; + A1E70D150A38B5BB007BE3E3 /* NTMakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NTMakefile; sourceTree = ""; }; + A1E70D170A38B5BB007BE3E3 /* implementation-notes.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "implementation-notes.txt"; sourceTree = ""; }; + A1E70D190A38B5BB007BE3E3 /* cc_rpc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = cc_rpc.h; sourceTree = ""; }; + A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CredentialsCache.h; sourceTree = ""; }; + A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CredentialsCache2.h; sourceTree = ""; }; + A1E70D1C0A38B5BB007BE3E3 /* datastore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = datastore.h; sourceTree = ""; }; + A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = generic_lists.h; sourceTree = ""; }; + A1E70D1E0A38B5BB007BE3E3 /* marshall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = marshall.h; sourceTree = ""; }; + A1E70D1F0A38B5BB007BE3E3 /* msg.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = msg.h; sourceTree = ""; }; + A1E70D200A38B5BB007BE3E3 /* msg_headers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = msg_headers.h; sourceTree = ""; }; + A1E70D210A38B5BB007BE3E3 /* rpc_auth.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = rpc_auth.h; sourceTree = ""; }; + A1E70D260A38B5BB007BE3E3 /* NTMakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = NTMakefile; path = ../NTMakefile; sourceTree = SOURCE_ROOT; }; + A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccs_ccache.c; sourceTree = ""; }; + A1E70D290A38B5BB007BE3E3 /* ccs_context.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccs_context.c; sourceTree = ""; }; + A1E70D2A0A38B5BB007BE3E3 /* ccs_lists.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ccs_lists.c; sourceTree = ""; }; + A1E70D2C0A38B5BB007BE3E3 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; + A1E70D2D0A38B5BB007BE3E3 /* NTMakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NTMakefile; sourceTree = ""; }; + A1E70D2E0A38B5BB007BE3E3 /* rpc_auth.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rpc_auth.c; sourceTree = ""; }; + A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = serv_ops.c; sourceTree = ""; }; + A1E70D300A38B5BB007BE3E3 /* serv_ops.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = serv_ops.h; sourceTree = ""; }; + A1E70D330A38B5BB007BE3E3 /* NTMakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NTMakefile; sourceTree = ""; }; + A1E70D340A38B5BB007BE3E3 /* t_ccache.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = t_ccache.c; sourceTree = ""; }; + A1E70D350A38B5BB007BE3E3 /* t_context.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = t_context.c; sourceTree = ""; }; + A1E70D360A38B5BB007BE3E3 /* t_lists.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = t_lists.c; sourceTree = ""; }; + A1E70D370A38B5BB007BE3E3 /* t_msg.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = t_msg.c; sourceTree = ""; }; + A1E70D380A38B5BB007BE3E3 /* t_server.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = t_server.c; sourceTree = ""; }; + A1E70D3A0A38B5BB007BE3E3 /* cacheapi.def */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = cacheapi.def; sourceTree = ""; }; + A1E70D3B0A38B5BB007BE3E3 /* client.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = client.c; sourceTree = ""; }; + A1E70D3C0A38B5BB007BE3E3 /* dllmain.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = dllmain.c; sourceTree = ""; }; + A1E70D3D0A38B5BC007BE3E3 /* ntccrpc.acf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ntccrpc.acf; sourceTree = ""; }; + A1E70D3E0A38B5BC007BE3E3 /* ntccrpc.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ntccrpc.idl; sourceTree = ""; }; + A1E70D3F0A38B5BC007BE3E3 /* NTMakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NTMakefile; sourceTree = ""; }; + A1E70D410A38B5BC007BE3E3 /* client.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = client.c; sourceTree = ""; }; + A1E70D420A38B5BC007BE3E3 /* cstest.acf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = cstest.acf; sourceTree = ""; }; + A1E70D430A38B5BC007BE3E3 /* cstest.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = cstest.idl; sourceTree = ""; }; + A1E70D440A38B5BC007BE3E3 /* NTMakefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = NTMakefile; sourceTree = ""; }; + A1E70D450A38B5BC007BE3E3 /* server.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = server.c; sourceTree = ""; }; + A1E70D460A38B5BC007BE3E3 /* server.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = server.c; sourceTree = ""; }; + A1E70D5D0A38B796007BE3E3 /* CCacheServer.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = CCacheServer.app; sourceTree = BUILT_PRODUCTS_DIR; }; + A1E70D910A38BB67007BE3E3 /* CCacheServer.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = CCacheServer.plist; sourceTree = ""; }; + A1E70D920A38BB67007BE3E3 /* CCacheServerInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = CCacheServerInfo.plist; sourceTree = ""; }; + A1E70D930A38BB67007BE3E3 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = ""; }; + A1E70D9E0A38BCAD007BE3E3 /* mig.defs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.mig; path = mig.defs; sourceTree = ""; }; + A1E70DB10A38C01E007BE3E3 /* mig_types.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mig_types.h; sourceTree = ""; }; + A1E70DE00A38C6FD007BE3E3 /* kipc_client.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = kipc_client.h; sourceTree = ""; }; + A1E70DE10A38C6FD007BE3E3 /* kipc_common.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = kipc_common.h; sourceTree = ""; }; + A1E70DE20A38C6FD007BE3E3 /* kipc_server.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = kipc_server.h; sourceTree = ""; }; + A1E70DE30A38C6FD007BE3E3 /* kipc_session.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = kipc_session.h; sourceTree = ""; }; + A1E70DE40A38C6FD007BE3E3 /* kipc_client.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = kipc_client.c; sourceTree = ""; }; + A1E70DE50A38C6FD007BE3E3 /* kipc_common.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = kipc_common.c; sourceTree = ""; }; + A1E70DE60A38C6FD007BE3E3 /* kipc_server.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = kipc_server.c; sourceTree = ""; }; + A1E70DE70A38C6FD007BE3E3 /* kipc_session.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = kipc_session.c; sourceTree = ""; }; + A1E70DE80A38C6FD007BE3E3 /* notify.defs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.mig; path = notify.defs; sourceTree = ""; }; + A1E70DE90A38C6FD007BE3E3 /* README */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README; sourceTree = ""; }; + D2AAC046055464E500DB518D /* libCCAPI.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCCAPI.a; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + A1E70D5B0A38B796007BE3E3 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D289987405E68DCB004EDB86 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 08FB7794FE84155DC02AAC07 /* CCAPI */ = { + isa = PBXGroup; + children = ( + A1E70CFF0A38B5BB007BE3E3 /* client */, + A1E70D110A38B5BB007BE3E3 /* common */, + A1E70D160A38B5BB007BE3E3 /* doc */, + A1E70D180A38B5BB007BE3E3 /* include */, + A1E70D260A38B5BB007BE3E3 /* NTMakefile */, + A1E70D270A38B5BB007BE3E3 /* server */, + A1E70D320A38B5BB007BE3E3 /* unit-test */, + A1E70D390A38B5BB007BE3E3 /* windows */, + 1AB674ADFE9D54B511CA2CBB /* Products */, + ); + name = CCAPI; + sourceTree = ""; + }; + 1AB674ADFE9D54B511CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + D2AAC046055464E500DB518D /* libCCAPI.a */, + A1E70D5D0A38B796007BE3E3 /* CCacheServer.app */, + ); + name = Products; + sourceTree = ""; + }; + A1E70CFF0A38B5BB007BE3E3 /* client */ = { + isa = PBXGroup; + children = ( + A1E70D000A38B5BB007BE3E3 /* cacheapi.c */, + A1E70D010A38B5BB007BE3E3 /* ccache.c */, + A1E70D020A38B5BB007BE3E3 /* ccache.h */, + A1E70D030A38B5BB007BE3E3 /* ccache_iterator.c */, + A1E70D040A38B5BB007BE3E3 /* ccache_iterator.h */, + A1E70D050A38B5BB007BE3E3 /* ccapiv2.c */, + A1E70D060A38B5BB007BE3E3 /* ccstring.c */, + A1E70D070A38B5BB007BE3E3 /* ccstring.h */, + A1E70D080A38B5BB007BE3E3 /* context.c */, + A1E70D090A38B5BB007BE3E3 /* context.h */, + A1E70D0A0A38B5BB007BE3E3 /* credentials.c */, + A1E70D0B0A38B5BB007BE3E3 /* credentials.h */, + A1E70D0C0A38B5BB007BE3E3 /* credentials_iterator.c */, + A1E70D0D0A38B5BB007BE3E3 /* credentials_iterator.h */, + A1E70D0E0A38B5BB007BE3E3 /* mac */, + A1E70D0F0A38B5BB007BE3E3 /* NTMakefile */, + A1E70D100A38B5BB007BE3E3 /* windows */, + ); + name = client; + path = ../client; + sourceTree = SOURCE_ROOT; + }; + A1E70D0E0A38B5BB007BE3E3 /* mac */ = { + isa = PBXGroup; + children = ( + ); + path = mac; + sourceTree = ""; + }; + A1E70D100A38B5BB007BE3E3 /* windows */ = { + isa = PBXGroup; + children = ( + ); + path = windows; + sourceTree = ""; + }; + A1E70D110A38B5BB007BE3E3 /* common */ = { + isa = PBXGroup; + children = ( + A1E70D7E0A38BAC5007BE3E3 /* mac */, + A1E70D120A38B5BB007BE3E3 /* generic_lists.c */, + A1E70D130A38B5BB007BE3E3 /* marshall.c */, + A1E70D140A38B5BB007BE3E3 /* msg.c */, + A1E70D150A38B5BB007BE3E3 /* NTMakefile */, + ); + name = common; + path = ../common; + sourceTree = SOURCE_ROOT; + }; + A1E70D160A38B5BB007BE3E3 /* doc */ = { + isa = PBXGroup; + children = ( + A1E70D170A38B5BB007BE3E3 /* implementation-notes.txt */, + ); + name = doc; + path = ../doc; + sourceTree = SOURCE_ROOT; + }; + A1E70D180A38B5BB007BE3E3 /* include */ = { + isa = PBXGroup; + children = ( + A1E70D190A38B5BB007BE3E3 /* cc_rpc.h */, + A1E70D1A0A38B5BB007BE3E3 /* CredentialsCache.h */, + A1E70D1B0A38B5BB007BE3E3 /* CredentialsCache2.h */, + A1E70D1C0A38B5BB007BE3E3 /* datastore.h */, + A1E70D1D0A38B5BB007BE3E3 /* generic_lists.h */, + A1E70D1E0A38B5BB007BE3E3 /* marshall.h */, + A1E70D1F0A38B5BB007BE3E3 /* msg.h */, + A1E70D200A38B5BB007BE3E3 /* msg_headers.h */, + A1E70D210A38B5BB007BE3E3 /* rpc_auth.h */, + ); + name = include; + path = ../include; + sourceTree = SOURCE_ROOT; + }; + A1E70D270A38B5BB007BE3E3 /* server */ = { + isa = PBXGroup; + children = ( + A1E70D280A38B5BB007BE3E3 /* ccs_ccache.c */, + A1E70D290A38B5BB007BE3E3 /* ccs_context.c */, + A1E70D2A0A38B5BB007BE3E3 /* ccs_lists.c */, + A1E70D2B0A38B5BB007BE3E3 /* mac */, + A1E70D2C0A38B5BB007BE3E3 /* main.c */, + A1E70D2D0A38B5BB007BE3E3 /* NTMakefile */, + A1E70D2E0A38B5BB007BE3E3 /* rpc_auth.c */, + A1E70D2F0A38B5BB007BE3E3 /* serv_ops.c */, + A1E70D300A38B5BB007BE3E3 /* serv_ops.h */, + A1E70D310A38B5BB007BE3E3 /* windows */, + ); + name = server; + path = ../server; + sourceTree = SOURCE_ROOT; + }; + A1E70D2B0A38B5BB007BE3E3 /* mac */ = { + isa = PBXGroup; + children = ( + A1E70D910A38BB67007BE3E3 /* CCacheServer.plist */, + A1E70D920A38BB67007BE3E3 /* CCacheServerInfo.plist */, + A1E70D930A38BB67007BE3E3 /* main.c */, + ); + path = mac; + sourceTree = ""; + }; + A1E70D310A38B5BB007BE3E3 /* windows */ = { + isa = PBXGroup; + children = ( + ); + path = windows; + sourceTree = ""; + }; + A1E70D320A38B5BB007BE3E3 /* unit-test */ = { + isa = PBXGroup; + children = ( + A1E70D330A38B5BB007BE3E3 /* NTMakefile */, + A1E70D340A38B5BB007BE3E3 /* t_ccache.c */, + A1E70D350A38B5BB007BE3E3 /* t_context.c */, + A1E70D360A38B5BB007BE3E3 /* t_lists.c */, + A1E70D370A38B5BB007BE3E3 /* t_msg.c */, + A1E70D380A38B5BB007BE3E3 /* t_server.c */, + ); + name = "unit-test"; + path = "../unit-test"; + sourceTree = SOURCE_ROOT; + }; + A1E70D390A38B5BB007BE3E3 /* windows */ = { + isa = PBXGroup; + children = ( + A1E70D3A0A38B5BB007BE3E3 /* cacheapi.def */, + A1E70D3B0A38B5BB007BE3E3 /* client.c */, + A1E70D3C0A38B5BB007BE3E3 /* dllmain.c */, + A1E70D3D0A38B5BC007BE3E3 /* ntccrpc.acf */, + A1E70D3E0A38B5BC007BE3E3 /* ntccrpc.idl */, + A1E70D3F0A38B5BC007BE3E3 /* NTMakefile */, + A1E70D400A38B5BC007BE3E3 /* rpcsstest */, + A1E70D460A38B5BC007BE3E3 /* server.c */, + ); + name = windows; + path = ../windows; + sourceTree = SOURCE_ROOT; + }; + A1E70D400A38B5BC007BE3E3 /* rpcsstest */ = { + isa = PBXGroup; + children = ( + A1E70D410A38B5BC007BE3E3 /* client.c */, + A1E70D420A38B5BC007BE3E3 /* cstest.acf */, + A1E70D430A38B5BC007BE3E3 /* cstest.idl */, + A1E70D440A38B5BC007BE3E3 /* NTMakefile */, + A1E70D450A38B5BC007BE3E3 /* server.c */, + ); + path = rpcsstest; + sourceTree = ""; + }; + A1E70D7E0A38BAC5007BE3E3 /* mac */ = { + isa = PBXGroup; + children = ( + A1E70DDE0A38C6FD007BE3E3 /* KerberosIPC */, + A1E70D9E0A38BCAD007BE3E3 /* mig.defs */, + A1E70DB10A38C01E007BE3E3 /* mig_types.h */, + ); + path = mac; + sourceTree = ""; + }; + A1E70DDE0A38C6FD007BE3E3 /* KerberosIPC */ = { + isa = PBXGroup; + children = ( + A1E70DDF0A38C6FD007BE3E3 /* Kerberos */, + A1E70DE40A38C6FD007BE3E3 /* kipc_client.c */, + A1E70DE50A38C6FD007BE3E3 /* kipc_common.c */, + A1E70DE60A38C6FD007BE3E3 /* kipc_server.c */, + A1E70DE70A38C6FD007BE3E3 /* kipc_session.c */, + A1E70DE80A38C6FD007BE3E3 /* notify.defs */, + A1E70DE90A38C6FD007BE3E3 /* README */, + ); + path = KerberosIPC; + sourceTree = ""; + }; + A1E70DDF0A38C6FD007BE3E3 /* Kerberos */ = { + isa = PBXGroup; + children = ( + A1E70DE00A38C6FD007BE3E3 /* kipc_client.h */, + A1E70DE10A38C6FD007BE3E3 /* kipc_common.h */, + A1E70DE20A38C6FD007BE3E3 /* kipc_server.h */, + A1E70DE30A38C6FD007BE3E3 /* kipc_session.h */, + ); + path = Kerberos; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + D2AAC043055464E500DB518D /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + A1E70D5C0A38B796007BE3E3 /* CCacheServer */ = { + isa = PBXNativeTarget; + buildConfigurationList = A1E70D600A38B797007BE3E3 /* Build configuration list for PBXNativeTarget "CCacheServer" */; + buildPhases = ( + A1E70D590A38B796007BE3E3 /* Resources */, + A1E70D5A0A38B796007BE3E3 /* Sources */, + A1E70D5B0A38B796007BE3E3 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CCacheServer; + productName = CCacheServer; + productReference = A1E70D5D0A38B796007BE3E3 /* CCacheServer.app */; + productType = "com.apple.product-type.application"; + }; + D2AAC045055464E500DB518D /* CCAPI */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1DEB91EB08733DB70010E9CD /* Build configuration list for PBXNativeTarget "CCAPI" */; + buildPhases = ( + D2AAC043055464E500DB518D /* Headers */, + D2AAC044055464E500DB518D /* Sources */, + D289987405E68DCB004EDB86 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CCAPI; + productName = CCAPI; + productReference = D2AAC046055464E500DB518D /* libCCAPI.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 08FB7793FE84155DC02AAC07 /* Project object */ = { + isa = PBXProject; + buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "CCAPI" */; + hasScannedForEncodings = 1; + mainGroup = 08FB7794FE84155DC02AAC07 /* CCAPI */; + projectDirPath = ""; + targets = ( + D2AAC045055464E500DB518D /* CCAPI */, + A1E70D5C0A38B796007BE3E3 /* CCacheServer */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + A1E70D590A38B796007BE3E3 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + A1E70D5A0A38B796007BE3E3 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A1E70DA00A38BCAD007BE3E3 /* mig.defs in Sources */, + A1E70DF00A38C71D007BE3E3 /* notify.defs in Sources */, + A1E70D9B0A38BBE2007BE3E3 /* main.c in Sources */, + A1E70D890A38BB47007BE3E3 /* ccs_ccache.c in Sources */, + A1E70D8A0A38BB47007BE3E3 /* ccs_context.c in Sources */, + A1E70D8B0A38BB47007BE3E3 /* ccs_lists.c in Sources */, + A1E70D8C0A38BB47007BE3E3 /* rpc_auth.c in Sources */, + A1E70D8D0A38BB47007BE3E3 /* serv_ops.c in Sources */, + A1E70D8E0A38BB4F007BE3E3 /* generic_lists.c in Sources */, + A1E70D8F0A38BB4F007BE3E3 /* marshall.c in Sources */, + A1E70D900A38BB4F007BE3E3 /* msg.c in Sources */, + A1E70DED0A38C71D007BE3E3 /* kipc_common.c in Sources */, + A1E70DEE0A38C71D007BE3E3 /* kipc_server.c in Sources */, + A1E70DEF0A38C71D007BE3E3 /* kipc_session.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D2AAC044055464E500DB518D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + A1E70D9F0A38BCAD007BE3E3 /* mig.defs in Sources */, + A1E70D480A38B5D5007BE3E3 /* cacheapi.c in Sources */, + A1E70D490A38B5D5007BE3E3 /* ccache.c in Sources */, + A1E70D4A0A38B5D5007BE3E3 /* ccache_iterator.c in Sources */, + A1E70D4B0A38B5D5007BE3E3 /* ccapiv2.c in Sources */, + A1E70D4C0A38B5D5007BE3E3 /* ccstring.c in Sources */, + A1E70D4D0A38B5D5007BE3E3 /* context.c in Sources */, + A1E70D4E0A38B5D5007BE3E3 /* credentials.c in Sources */, + A1E70D4F0A38B5D5007BE3E3 /* credentials_iterator.c in Sources */, + A1E70D510A38B60C007BE3E3 /* generic_lists.c in Sources */, + A1E70D520A38B60C007BE3E3 /* marshall.c in Sources */, + A1E70D530A38B60C007BE3E3 /* msg.c in Sources */, + A1E70DEA0A38C710007BE3E3 /* kipc_client.c in Sources */, + A1E70DEB0A38C710007BE3E3 /* kipc_common.c in Sources */, + A1E70DEC0A38C710007BE3E3 /* kipc_session.c in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1DEB91EC08733DB70010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + GCC_DYNAMIC_NO_PIC = NO; + HEADER_SEARCH_PATHS = ( + "$(inherited)", + ../client, + ../client/mac, + ../common, + ../common/mac, + ../common/mac/KerberosIPC, + ); + PRODUCT_NAME = CCAPI; + }; + name = Debug; + }; + 1DEB91ED08733DB70010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + ../client, + ../client/mac, + ../common, + ../common/mac, + ../common/mac/KerberosIPC, + ); + PRODUCT_NAME = CCAPI; + }; + name = Release; + }; + 1DEB91F008733DB70010E9CD /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = ( + i386, + ppc, + ); + COPY_PHASE_STRIP = NO; + GCC_ENABLE_FIX_AND_CONTINUE = YES; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + PREBINDING = NO; + ZERO_LINK = YES; + }; + name = Debug; + }; + 1DEB91F108733DB70010E9CD /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(NATIVE_ARCH)"; + COPY_PHASE_STRIP = YES; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_GENERATE_DEBUGGING_SYMBOLS = YES; + GCC_OPTIMIZATION_LEVEL = 3; + PREBINDING = NO; + ZERO_LINK = NO; + }; + name = Release; + }; + A1E70D610A38B797007BE3E3 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + ../server, + ../server/mac, + ../common, + ../common/mac, + ../common/mac/KerberosIPC, + ); + INFOPLIST_FILE = ../server/mac/CCacheServerInfo.plist; + INSTALL_PATH = /System/Library/CoreServices; + PRODUCT_NAME = CCacheServer; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + A1E70D620A38B797007BE3E3 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + HEADER_SEARCH_PATHS = ( + "$(inherited)", + ../server, + ../server/mac, + ../common, + ../common/mac, + ../common/mac/KerberosIPC, + ); + INFOPLIST_FILE = ../server/mac/CCacheServerInfo.plist; + INSTALL_PATH = /System/Library/CoreServices; + PRODUCT_NAME = CCacheServer; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1DEB91EB08733DB70010E9CD /* Build configuration list for PBXNativeTarget "CCAPI" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB91EC08733DB70010E9CD /* Debug */, + 1DEB91ED08733DB70010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "CCAPI" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1DEB91F008733DB70010E9CD /* Debug */, + 1DEB91F108733DB70010E9CD /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A1E70D600A38B797007BE3E3 /* Build configuration list for PBXNativeTarget "CCacheServer" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A1E70D610A38B797007BE3E3 /* Debug */, + A1E70D620A38B797007BE3E3 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; +} diff --git a/src/lib/ccapi/marshall.c b/src/lib/ccapi/marshall.c deleted file mode 100644 index 7027d65612..0000000000 --- a/src/lib/ccapi/marshall.c +++ /dev/null @@ -1,378 +0,0 @@ -/* $Copyright: - * - * Copyright 2004 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 MIT 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. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* marshall.c */ - -#include -#include -#include -#include "msg.h" -#include "msg_headers.h" -#include "marshall.h" - -cc_int32 -cci_creds_v4_marshall( cc_credentials_v4_t * creds, - char ** flat, - cc_uint32 * len) -{ - cc_msg_t * msg; - ccmsg_creds_v4_t * header; - cc_uint32 blob_pos; - cc_int32 code; - - if ( creds == NULL || flat == NULL || len == NULL ) - return ccErrBadParam; - - header = (ccmsg_creds_v4_t *)malloc(sizeof(ccmsg_creds_v4_t)); - if ( header == NULL ) - return ccErrNoMem; - - code = cci_msg_new(ccmsg_CREDS_V4, &msg); - - code = cci_msg_add_header(msg, header, sizeof(ccmsg_creds_v4_t)); - - code = cci_msg_add_data_blob(msg, creds, sizeof(cc_credentials_v4_t), &blob_pos); - - header->offset = blob_pos; - header->len = sizeof(cc_credentials_v4_t); - - code = cci_msg_flatten( msg, NULL ); - - *flat = msg->flat; - *len = msg->flat_len; - msg->flat = NULL; - msg->flat_len = 0; - - cci_msg_destroy(msg); - - return ccNoError; -} - -cc_int32 -cci_creds_v4_unmarshall( char * flat, - cc_uint32 len, - cc_credentials_union * creds) -{ - cc_msg_t * msg; - ccmsg_creds_v4_t * header; - cc_int32 code; - - if ( flat == NULL || len == 0 || creds == NULL ) - return ccErrBadParam; - - code = cci_msg_unflatten( flat, len, &msg ); - - header = (ccmsg_creds_v4_t *)msg->header; - - creds->version = cc_credentials_v4; - code = cci_msg_retrieve_blob(msg, header->offset, header->len, &creds->credentials.credentials_v4); - - cci_msg_destroy(msg); - - return ccNoError; -} - - -cc_int32 -cci_creds_cc_data_array_count_entries( cc_data ** array, cc_uint32 * pcount) -{ - cc_uint32 count; - - if (array == NULL) { - *pcount = 0; - return ccNoError; - } - - for ( count=0; array[count] != NULL ; count++) ; - - *pcount = count; - return ccNoError; -} - -cc_int32 -cci_creds_v5_compute_flat_size( cc_credentials_v5_t * creds, cc_uint32 * plen) -{ - cc_uint32 len; - cc_uint32 i, count; - - len = sizeof(struct cci_flat_creds_v5); - - if (creds->client) - len += strlen(creds->client) + 1; - - if (creds->server) - len += strlen(creds->server) + 1; - - len += creds->keyblock.length; - - cci_creds_cc_data_array_count_entries( creds->addresses, &count ); - len += count * sizeof(cc_flat_data); - for ( i=0; iaddresses[i]->length; - } - - len += creds->ticket.length; - len += creds->second_ticket.length; - - cci_creds_cc_data_array_count_entries( creds->authdata, &count ); - len += count * sizeof(cc_flat_data); - for ( i=0; iauthdata[i]->length; - } - - *plen = len; - return ccNoError; -} - -cc_int32 -cci_creds_v5_marshall( cc_credentials_v5_t * creds, - char ** pflat, - cc_uint32 * plen) -{ - cc_uint32 len; - char * flat; - struct cci_flat_creds_v5 * header; - cc_uint32 offset; - cc_uint32 i; - - if ( creds == NULL || pflat == NULL || plen == NULL ) - return ccErrBadParam; - - cci_creds_v5_compute_flat_size(creds, &len); - - flat = (char *)malloc(len); - if ( flat == NULL ) - return ccErrNoMem; - memset(flat, 0, len); - - offset = sizeof(struct cci_flat_creds_v5); - header = (struct cci_flat_creds_v5 *)flat; - header->version = FLAT_CREDS_V5_VERSION; - if (creds->client) { - header->client.length = strlen(creds->client) + 1; - header->client.data = offset; - memcpy(flat + offset, creds->client, header->client.length); - offset += header->client.length; - } - - if (creds->server) { - header->server.length = strlen(creds->server) + 1; - header->server.data = offset; - memcpy(flat + offset, creds->server, header->server.length); - offset += header->server.length; - } - - header->keyblock.type = creds->keyblock.type; - if (creds->keyblock.length) { - header->keyblock.length = creds->keyblock.length; - header->keyblock.data = offset; - memcpy(flat + offset, creds->keyblock.data, header->keyblock.length); - offset += header->keyblock.length; - } - - header->authtime = creds->authtime; - header->starttime = creds->starttime; - header->endtime = creds->endtime; - header->renew_till = creds->renew_till; - header->is_skey = creds->is_skey; - header->ticket_flags = creds->ticket_flags; - - cci_creds_cc_data_array_count_entries( creds->addresses, &header->address_count ); - if ( header->address_count ) { - cc_flat_data * addresses = (cc_flat_data *)flat + offset; - header->addresses = offset; - offset += header->address_count * sizeof(cc_flat_data); - - for ( i=0; iaddress_count; i++ ) { - addresses[i].type = creds->addresses[i]->type; - if (creds->addresses[i]->length) { - addresses[i].length = creds->addresses[i]->length; - addresses[i].data = offset; - memcpy(flat + offset, creds->addresses[i]->data, addresses[i].length); - offset += addresses[i].length; - } - } - } - - header->ticket.type = creds->ticket.type; - if (creds->ticket.length) { - header->ticket.length = creds->ticket.length; - header->ticket.data = offset; - memcpy(flat + offset, creds->ticket.data, header->ticket.length); - offset += header->ticket.length; - } - - header->second_ticket.type = creds->second_ticket.type; - if (creds->second_ticket.length) { - header->second_ticket.length = creds->second_ticket.length; - header->second_ticket.data = offset; - memcpy(flat + offset, creds->second_ticket.data, header->second_ticket.length); - offset += header->second_ticket.length; - } - - cci_creds_cc_data_array_count_entries( creds->authdata, &header->authdata_count ); - if ( header->authdata_count ) { - cc_flat_data * authdata = (cc_flat_data *)flat + offset; - header->authdata = offset; - offset += header->authdata_count * sizeof(cc_flat_data); - - for ( i=0; iauthdata_count; i++ ) { - authdata[i].type = creds->authdata[i]->type; - if (creds->authdata[i]->length) { - authdata[i].length = creds->authdata[i]->length; - authdata[i].data = offset; - memcpy(flat + offset, creds->authdata[i]->data, authdata[i].length); - offset += authdata[i].length; - } - } - } - - *pflat = flat; - *plen = len; - return ccNoError; -} - - -// TODO: a much better job of checking for out of memory errors -// and validating that we do not read beyond the flat input -// data buffer - -cc_int32 -cci_creds_v5_unmarshall( char * flat, - cc_uint32 len, - cc_credentials_union * creds_union) -{ - struct cci_flat_creds_v5 * header; - cc_credentials_v5_t * creds; - cc_flat_data * flat_data; - cc_uint32 i; - cc_int32 code; - - if ( flat == NULL || len == 0 || creds_union == NULL ) - return ccErrBadParam; - - creds_union->version = cc_credentials_v5; - - header = (struct cci_flat_creds_v5 *)flat; - - if ( header->version != FLAT_CREDS_V5_VERSION ) - return ccErrBadParam; - - creds = (cc_credentials_v5_t *)malloc(sizeof(cc_credentials_v5_t)); - if ( creds == NULL ) - return ccErrNoMem; - memset(creds, 0, sizeof(ccmsg_creds_v5_t)); - - if ( header->client.length ) { - creds->client = (char *)malloc(header->client.length); - memcpy(creds->client, flat + header->client.data, header->client.length); - } - - if ( header->server.length ) { - creds->server = (char *)malloc(header->server.length); - memcpy(creds->server, flat + header->server.data, header->server.length); - } - - creds->keyblock.type = header->keyblock.type; - if ( header->keyblock.length ) { - creds->keyblock.length = header->keyblock.length; - creds->keyblock.data = malloc(creds->keyblock.length); - memcpy(creds->keyblock.data, flat + header->keyblock.data, creds->keyblock.length); - } - - creds->authtime = header->authtime; - creds->starttime = header->starttime; - creds->endtime = header->endtime; - creds->renew_till = header->renew_till; - creds->is_skey = header->is_skey; - creds->ticket_flags = header->ticket_flags; - - creds->addresses = (cc_data **) malloc((header->address_count + 1) * sizeof(cc_data *)); - flat_data = (cc_flat_data *)flat + header->addresses; - for ( i=0 ; i < header->address_count ; i++ ) { - creds->addresses[i] = (cc_data *)malloc(sizeof(cc_data)); - creds->addresses[i]->type = flat_data[i].type; - creds->addresses[i]->length = flat_data[i].length; - if ( flat_data[i].length ) { - creds->addresses[i]->data = malloc(flat_data[i].length); - memcpy(creds->addresses[i]->data, flat + flat_data[i].data, flat_data[i].length); - } else { - creds->addresses[i]->data = NULL; - } - } - creds->addresses[i] = NULL; - - creds->ticket.type = header->ticket.type; - if ( header->ticket.length ) { - creds->ticket.length = header->ticket.length; - creds->ticket.data = malloc(creds->ticket.length); - memcpy(creds->ticket.data, flat + header->ticket.data, creds->ticket.length); - } - - creds->second_ticket.type = header->second_ticket.type; - if ( header->second_ticket.length ) { - creds->second_ticket.length = header->second_ticket.length; - creds->second_ticket.data = malloc(creds->second_ticket.length); - memcpy(creds->second_ticket.data, flat + header->second_ticket.data, creds->second_ticket.length); - } - - creds->authdata = (cc_data **) malloc((header->authdata_count + 1) * sizeof(cc_data *)); - flat_data = (cc_flat_data *)flat + header->authdata; - for ( i=0 ; i < header->authdata_count ; i++ ) { - creds->authdata[i] = (cc_data *)malloc(sizeof(cc_data)); - creds->authdata[i]->type = flat_data[i].type; - creds->authdata[i]->length = flat_data[i].length; - if ( flat_data[i].length ) { - creds->authdata[i]->data = malloc(flat_data[i].length); - memcpy(creds->authdata[i]->data, flat + flat_data[i].data, flat_data[i].length); - } else { - creds->authdata[i]->data = NULL; - } - } - creds->authdata[i] = NULL; - - creds_union->credentials.credentials_v5 = creds; - - return ccNoError; -} - diff --git a/src/lib/ccapi/server/NTMakefile b/src/lib/ccapi/server/NTMakefile index 671b6905f2..564097c534 100644 --- a/src/lib/ccapi/server/NTMakefile +++ b/src/lib/ccapi/server/NTMakefile @@ -1,30 +1,21 @@ -# Makefile for the CCAPI Generic Server +# Makefile for the CCAPI Server Library !INCLUDE -CFLAGS = -I../include +CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsmt) -CCAPI_LIB = ../lib/ccapi.lib -WINLIBS = user32.lib advapi32.lib -CCSOBJS = context.obj ccache.obj lists.obj rpc_auth.obj serv_ops.obj +CC_SERVER_OBJS = ccs_context.obj ccs_ccache.obj ccs_lists.obj rpc_auth.obj serv_ops.obj -all: t_lists.exe t_msg.exe t_ccache.exe t_context.exe ccapi_server.exe +CC_SERVER_LIB = cc_server.lib -t_lists.exe: t_lists.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ t_lists.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) +CC_COMMON_LIB = ../common/cc_common.lib -t_msg.exe: t_msg.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ t_msg.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) +$(CC_SERVER_LIB): $(CC_SERVER_OBJS) + $(implib) /NOLOGO /OUT:$@ $** -t_ccache.exe: t_ccache.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ t_ccache.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) - -t_context.exe: t_context.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ t_context.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) - -ccapi_server.exe: main.obj $(CCSOBJS) $(CCAPI_LIB) - link -out:$@ main.obj $(CCSOBJS) $(CCAPI_LIB) $(WINLIBS) +all: $(CC_SERVER_LIB) clean: - del *.obj *.exe + del *.obj *.lib + \ No newline at end of file diff --git a/src/lib/ccapi/server/ccache.c b/src/lib/ccapi/server/ccs_ccache.c similarity index 83% rename from src/lib/ccapi/server/ccache.c rename to src/lib/ccapi/server/ccs_ccache.c index 2c3a745afe..d632ee3494 100644 --- a/src/lib/ccapi/server/ccache.c +++ b/src/lib/ccapi/server/ccs_ccache.c @@ -1,703 +1,703 @@ -/* $Copyright: - * - * Copyright 2004 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 MIT 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. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* - * Manages ccache objects. - * - */ - -#include -#include -#include -#include -#include "CredentialsCache.h" -#include "datastore.h" - -/** - * ccache_new() - * - * Purpose: Allocate and initialize new credentials cache for the specified principal - * and version - * - * Return: ccNoError - success - * ccErrInvalidString - name or principal is NULL - * ccErrBadCredentialsVersion - unsupported creds type - * ccErrBadParam - outCcachepp is NULL - * ccErrNoMem - malloc failed - */ -cc_int32 -cci_ccache_new( char *name, char *principal, int cred_vers, - cc_server_ccache_t** outCCachepp) -{ - cc_server_ccache_t* ccache; - - if (name == NULL || principal == NULL) - return ccErrInvalidString; - - if (cred_vers != cc_credentials_v4 && cred_vers != cc_credentials_v5 && - cred_vers != cc_credentials_v4_v5) - return ccErrBadCredentialsVersion; - - if (outCCachepp == NULL) - return ccErrBadParam; - - ccache = (cc_server_ccache_t*)malloc(sizeof(cc_server_ccache_t)); - if (ccache == NULL) - return ccErrNoMem; - - ccache->name = name; - ccache->principal_v4 = NULL; - ccache->principal_v5 = NULL; - ccache->changed = time(NULL); - ccache->kdc_offset = 0; - ccache->last_default = 0; - cci_generic_list_new(&ccache->active_iterators); - cci_credentials_list_new(&ccache->creds); - ccache->is_default = 0; - ccache->kdc_set = 0; - ccache->versions = cred_vers; - ccache->mycontext = NULL; - - cci_ccache_set_principal(ccache, cred_vers, principal); - *outCCachepp = ccache; - return ccNoError; -} - -/** - * cci_ccache_check_version() - * - * Purpose: Check to see if the ccache and the creds have compatible versions. - * - * Return: ccNoError and compat = 1 if they are compatible - * ccNoError and compat = 0 if they are not compatible - * - * Errors: ccErrInvalidCCache - ccache is NULL - * ccErrBadParam - either creds or compat are NULL - */ -cc_int32 -cci_ccache_check_version( const cc_server_ccache_t *ccache, - const cc_credentials_union* creds, - cc_uint32* compat) -{ - if (ccache == NULL) - return ccErrInvalidCCache; - - if (creds == NULL || compat == NULL) - return ccErrBadParam; - - if (ccache->versions == cc_credentials_v4_v5) - *compat = 1; - else if (ccache->versions == creds->version) - *compat = 1; - else - *compat = 0; - - return ccNoError; -} - -/** -cci_ccache_check_principal() - -Check to see if the client principal from the credentials matches -the principal associated with the cache. - -* Return: ccNoError and compat = 1 if they are compatible -* ccNoError and compat = 0 if they are not compatible -* -* Errors: ccErrInvalidCCache - ccache is NULL -* ccErrBadParam - either creds or compat are NULL -* ccErrBadCredentialVersion - unsupported credential type -*/ -cc_int32 -cci_ccache_check_principal( const cc_server_ccache_t *ccache, - const cc_credentials_union* creds, - cc_uint32* compat) -{ - if (ccache == NULL) - return ccErrInvalidCCache; - - if (creds == NULL || compat == NULL) - return ccErrBadParam; - - if (creds->version == cc_credentials_v4) { - if (strcmp(creds->credentials.credentials_v4->principal, ccache->principal_v4) == 0) - *compat = 1; - else - *compat = 0; - } else if (creds->version == cc_credentials_v5) { - if (strcmp(creds->credentials.credentials_v5->client, ccache->principal_v5) == 0) - *compat = 1; - else - *compat = 0; - } else { - return ccErrBadCredentialsVersion; - } - return ccNoError; -} - - -/** - * cci_ccache_store_creds() - * - * Purpose: Stores the provided credentials into the provided cache. Validates the - * ability of the cache to store credentials of the given version and client - * principal. - * - * Return: 0 on success - * -1 on error - * - * Errors: ccErrNoMem - * ccErrBadCredentialsVersion - * ccErrBadInvalidCredentials - * ccErrInvalidCache - * ccErrBadParam - */ -cc_int32 -cci_ccache_store_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials) -{ - cc_server_credentials_t* stored_cred=NULL; - cc_uint32 valid_version, valid_principal; - cc_int32 code; - - if (ccache == NULL) - return ccErrInvalidCCache; - - if (credentials == NULL) - return ccErrBadParam; - - code = cci_ccache_check_version(ccache, credentials, &valid_version); - if (code != ccNoError) { - /* pass error on to caller */ - goto bad; - } - code = cci_ccache_check_principal(ccache, credentials, &valid_principal); - if (code != ccNoError) { - /* pass error on to caller */ - goto bad; - } - if (valid_version && valid_principal) { - stored_cred = (cc_server_credentials_t*)malloc(sizeof(cc_server_credentials_t)); - if (stored_cred == NULL) { - code = ccErrNoMem; - goto bad; - } - memcpy(&stored_cred->creds, credentials, sizeof(cc_credentials_union)); - - if (credentials->version == cc_credentials_v4) { - stored_cred->creds.credentials.credentials_v4 = (cc_credentials_v4_t*)malloc(sizeof(cc_credentials_v4_t)); - if (stored_cred->creds.credentials.credentials_v4 == NULL) { - code = ccErrNoMem; - goto bad; - } - - memcpy(stored_cred->creds.credentials.credentials_v4, credentials->credentials.credentials_v4, sizeof(cc_credentials_v4_t)); - } else if (credentials->version == cc_credentials_v5) { - stored_cred->creds.credentials.credentials_v5 = (cc_credentials_v5_t*)malloc(sizeof(cc_credentials_v5_t)); - if (stored_cred->creds.credentials.credentials_v5 == NULL) { - code = ccErrNoMem; - goto bad; - } - - memcpy(stored_cred->creds.credentials.credentials_v5, credentials->credentials.credentials_v5, sizeof(cc_credentials_v5_t)); - } else { - code = ccErrBadCredentialsVersion; - goto bad; - } - - code = cci_credentials_list_append(ccache->creds, stored_cred, NULL); - if ( code != ccNoError ) { - /* pass error on to caller */ - goto bad; - } - if (ccache->creds->head->data == (cc_uint8 *)stored_cred) - stored_cred->is_default = 1; /*we're first on the list, so we're default*/ - - cci_ccache_changed(ccache); - return ccNoError; - } else { -#ifdef DEBUG - printf("vers: %d\tprincipal: %d\n", - valid_version, valid_principal); -#endif /* DEBUG */ - code = ccErrInvalidCredentials; - goto bad; - } - - bad: - if (stored_cred) - free(stored_cred); - return code; /* error */ -} - -/** - * cci_ccache_changed() - * - * Purpose: Updates the last update time for the ccache and its associated context. - * Provides a location from which interested parties should be notified - * of cache updates. - * - * Return: none - * - * Errors: none - */ -void -cci_ccache_changed(cc_server_ccache_t* ccache) -{ - ccache->changed = time(NULL); - if (ccache->mycontext != NULL) - ccache->mycontext->changed = time(NULL); - - /* XXX - notify registered listeners when implemented */ -} - -/** - * cci_ccache_rem_creds() - * - * Purpose: Removes the specified credential object from the specified cache if - * it exists - * - * Return: 0 on success (credential is not in the cache) - * -1 on error - * - * Errors: ccErrBadParam, ccErrNoMem (from cc_credentials_list_iterator) - * - * Verify: does the memory associated with stored_cred->creds need to be freed? - * - */ -cc_int32 -cci_ccache_rem_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials) -{ - cc_credentials_iterate_t* credentials_iterator=NULL, *active; - cc_generic_iterate_t* generic_iterator=NULL; - cc_credentials_list_node_t* credentials_node; - cc_generic_list_node_t* generic_node; - cc_server_credentials_t* stored_cred; - cc_int8 changed = 0; - cc_int32 code = 0; - - if (ccache == NULL) - return ccErrInvalidCCache; - - if (credentials == NULL) - return ccErrBadParam; - - code = cci_credentials_list_iterator(ccache->creds, &credentials_iterator); - if (code != ccNoError) { - /* pass error to caller */ - goto cleanup; - } - - while (cci_credentials_iterate_has_next(credentials_iterator)) { - code = cci_credentials_iterate_next(credentials_iterator, &credentials_node); - stored_cred = (cc_server_credentials_t*)credentials_node->data; - if (memcmp(&stored_cred->creds,credentials,sizeof(cc_credentials_union)) == 0) { - /* XXX - do we need to free(stored_cred->creds) ? */ - free(credentials_node->data); - changed = 1; - - /*If any iterator's next points to the deleted node, make it point to the next node*/ - code = cci_generic_list_iterator(ccache->active_iterators, &generic_iterator); - while (cci_generic_iterate_has_next(generic_iterator)) { - code = cci_generic_iterate_next(generic_iterator, &generic_node); - active = (cc_credentials_iterate_t*)generic_node->data; - if (active->next == credentials_node) - active->next = active->next->next; - } - code = cci_generic_free_iterator(generic_iterator); - generic_iterator = NULL; - - if (credentials_node == ccache->creds->head) { /*removing the default, must make next cred default*/ - code = cci_credentials_list_remove_element(ccache->creds, credentials_node); - - if (ccache->creds->head != NULL) - ((cc_server_credentials_t*)ccache->creds->head->data)->is_default = 1; - } else { - code = cci_credentials_list_remove_element(ccache->creds, credentials_node); - } - break; - } - } - - cleanup: - if (changed) - cci_ccache_changed(ccache); - if (credentials_iterator) - cci_credentials_free_iterator(credentials_iterator); - if (generic_iterator) - cci_generic_free_iterator(generic_iterator); - return code; -} - -/** - * cci_ccache_move() - * - * Purpose: Destroys the existing contents of the destination and copies - * all credentials from the source to the destination - * - * Return: 0 on success - * -1 on error - * - * Errors: ccBadNoMem - * - */ - -cc_int32 -cci_ccache_move(cc_server_ccache_t *source, cc_server_ccache_t* destination) -{ - cc_generic_list_node_t* node; - cc_generic_iterate_t* iterator; - cc_credentials_iterate_t* cur; - cc_int32 code; - - if (source == NULL || destination == NULL) - return ccErrBadParam; - - code = cci_credentials_list_destroy(destination->creds); - if ( code != ccNoError ) - return code; - - code = cci_credentials_list_copy(source->creds, &destination->creds); - if ( code != ccNoError ) - return code; - - destination->versions = source->versions; - destination->kdc_offset = source->kdc_offset; - destination->last_default = 0; - - /*reset all active iterators to point to the head of the new creds list*/ - if (destination->active_iterators->head != NULL) { - code = cci_generic_list_iterator(destination->active_iterators, &iterator); - while (cci_generic_iterate_has_next(iterator)) { - code = cci_generic_iterate_next(iterator, &node); - cur = (cc_credentials_iterate_t*)node->data; - cur->next = destination->creds->head; - } - code = cci_generic_free_iterator(iterator); - } - - cci_ccache_changed(destination); - return code; -} - -/** - * cci_ccache_get_kdc_time_offset() - * - * Purpose: Retrieves the kdc_time_offset from the ccache if set - * - * Return: 0 on success - * -1 on error - * - * Errors: ccErrBadParam, ccErrTimeOffsetNotSet - * - */ -cc_int32 -cci_ccache_get_kdc_time_offset(cc_server_ccache_t* ccache, cc_time_t* offset) -{ - if (ccache == NULL) - return ccErrInvalidCCache; - - if (offset == NULL) - return ccErrBadParam; - - if (!ccache->kdc_set) - return ccErrTimeOffsetNotSet; - - *offset = ccache->kdc_offset; - return ccNoError; -} - -/** - * cci_ccache_set_kdc_time_offset() - * - * Purpose: Sets the kdc time offset in the designated ccache - * - * Return: 0 on success - * -1 on error - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_ccache_set_kdc_time_offset(cc_server_ccache_t* ccache, cc_time_t offset) -{ - if (ccache == NULL) - return ccErrInvalidCCache; - - ccache->kdc_offset = offset; - ccache->kdc_set = 1; - cci_ccache_changed(ccache); - - return ccNoError; -} - -/** - * cci_ccache_clear_kdc_time_offset() - * - * Purpose: Clear the kdc time offset in the designated ccache - * - * Return: 0 on success - * -1 on error - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_ccache_clear_kdc_time_offset(cc_server_ccache_t* ccache) -{ - if (ccache == NULL) - return ccErrInvalidCCache; - - ccache->kdc_offset = 0; - ccache->kdc_set = 0; - cci_ccache_changed(ccache); - - return ccNoError; -} - -/** - * cci_ccache_new_iterator() - * - * Purpose: Retrieve an iterator for the designated cache - * - * Return: 0 on success - * -1 on error - * - * Errors: ccErrBadParam, ccBadNoMem - */ -cc_int32 -cci_ccache_new_iterator(cc_server_ccache_t* ccache, cc_credentials_iterate_t** iterator) -{ - cc_int32 code; - - if (ccache == NULL) - return ccErrInvalidCCache; - - if (iterator == NULL) - return ccErrBadParam; - - code = cci_credentials_list_iterator(ccache->creds, iterator); - if (code != ccNoError) - return code; - - code = cci_generic_list_prepend(ccache->active_iterators, *iterator, sizeof(cc_credentials_iterate_t), NULL); - if (code != ccNoError) - return code; - - return ccNoError; -} - -/** - * cci_ccache_get_principal() - * - * Purpose: Retrieves the client principal associated with the designated cache. - * The value is returned - * Return: - * - * Errors: - */ -cc_int32 -cci_ccache_get_principal(cc_server_ccache_t* ccache, cc_int32 version, char ** principal) -{ - char *p = NULL; - - switch ( version ) { - case cc_credentials_v4: - p = ccache->principal_v4; - break; - case cc_credentials_v5: - p = ccache->principal_v5; - break; - default: - return ccErrBadCredentialsVersion; - } - - *principal = (char *)malloc(strlen(p)+1); - if ( *principal == NULL ) - return ccErrNoMem; - - strcpy(*principal, p); - return ccNoError; -} - -/** - * Purpose: Releases the memory associated with a ccache principal - * - * Return: - * - * Errors: - * - */ -cc_int32 -cci_ccache_free_principal(char * principal) -{ - if ( principal == NULL ) - return ccErrBadParam; - - free(principal); - return ccNoError; -} - -/** - * ccache_set_principal() - * - * Purpose: Assigns a principal to the designated ccache and credential version. - * If the api version is 2, the cache is cleared of all existing - * credentials. - * - * Return: 0 on success - * -1 on error - * - * Errors: ccErrNoMem, ccErrBadCredentialsVersion - */ -cc_int32 -cci_ccache_set_principal( cc_server_ccache_t* ccache, cc_int32 cred_version, - char* principal) -{ - cc_generic_iterate_t* generic_iterator; - cc_generic_list_node_t* generic_node; - cc_ccache_iterate_t* ccache_iterator; - cc_int32 code = ccNoError; - - if (ccache == NULL) - return ccErrInvalidCCache; - - if (principal == NULL) - return ccErrInvalidString; - - switch (cred_version) { - case cc_credentials_v4: - case cc_credentials_v4_v5: - ccache->principal_v4 = (char *)malloc(strlen(principal) + 1); - if (ccache->principal_v4 == NULL) - return ccErrNoMem; - strcpy(ccache->principal_v4, principal); - if (cred_version != cc_credentials_v4_v5) - break; - /* fall-through if we are v4_v5 */ - case cc_credentials_v5: - ccache->principal_v5 = (char *)malloc(strlen(principal) + 1); - if (ccache->principal_v5 == NULL) { - if (cred_version == cc_credentials_v4_v5) { - free(ccache->principal_v4); - ccache->principal_v4 = NULL; - } - return ccErrNoMem; - } - strcpy(ccache->principal_v5, principal); - break; - default: - return ccErrBadCredentialsVersion; - } - - /*For API version 2 clients set_principal implies a flush of all creds*/ - if (ccache->mycontext != NULL && ccache->mycontext->api_version == ccapi_version_2) { - cci_credentials_list_destroy(ccache->creds); - cci_credentials_list_new(&ccache->creds); - - /*clean up active_iterators*/ - code = cci_generic_list_iterator(ccache->active_iterators, &generic_iterator); - if (code == ccNoError) { - while (cci_generic_iterate_has_next(generic_iterator)) { - code = cci_generic_iterate_next(generic_iterator, &generic_node); - ccache_iterator = (cc_ccache_iterate_t*)generic_node->data; - ccache_iterator->next = NULL; - } - } - } - - cci_ccache_changed(ccache); - - return code; -} - -/** - * cci_ccache_destroy() - * - * Purpose: Destroys an existing ccache - * - * Return: 0 on success - * -1 on errors - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_ccache_destroy(cc_server_ccache_t* ccache) -{ - cc_int32 code; - - if ( ccache == NULL ) - return ccErrInvalidCCache; - - code = cci_generic_list_destroy(ccache->active_iterators); - code = cci_credentials_list_destroy(ccache->creds); - - if (ccache->mycontext != NULL) - code = cci_context_rem_ccache(ccache->mycontext, ccache); - - return code; -} - -/** - * cci_ccache_compare() - * - * Purpose: Returns a boolean value indicating if two caches are identical - * Implemented as pointer equivalence. - * - * Return: 1 if TRUE - * 0 if FALSE - * - * Errors: No errors - */ -cc_int32 -cci_ccache_compare(cc_server_ccache_t* ccache1, cc_server_ccache_t* ccache2, cc_uint32 *result) -{ - if ( ccache1 == NULL || ccache2 == NULL ) - return ccErrInvalidCCache; - - if (ccache1 == ccache2) - *result = 1; - else - *result = 0; - - return ccNoError; -} - +/* $Copyright: + * + * Copyright 2004-2006 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 MIT 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. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Individual source code files are copyright MIT, Cygnus Support, + * OpenVision, Oracle, Sun Soft, FundsXpress, and others. + * + * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, + * and Zephyr are trademarks of the Massachusetts Institute of Technology + * (MIT). No commercial use of these trademarks may be made without prior + * written permission of MIT. + * + * "Commercial use" means use of a name in a product or other for-profit + * manner. It does NOT prevent a commercial firm from referring to the MIT + * trademarks in order to convey information (although in doing so, + * recognition of their trademark status should be given). + * $ + */ + +/* + * Manages ccache objects. + * + */ + +#include +#include +#include +#include +#include "CredentialsCache.h" +#include "datastore.h" + +/** + * ccache_new() + * + * Purpose: Allocate and initialize new credentials cache for the specified principal + * and version + * + * Return: ccNoError - success + * ccErrInvalidString - name or principal is NULL + * ccErrBadCredentialsVersion - unsupported creds type + * ccErrBadParam - outCcachepp is NULL + * ccErrNoMem - malloc failed + */ +cc_int32 +ccs_ccache_new( char *name, char *principal, int cred_vers, + cc_server_ccache_t** outCCachepp) +{ + cc_server_ccache_t* ccache; + + if (name == NULL || principal == NULL) + return ccErrInvalidString; + + if (cred_vers != cc_credentials_v4 && cred_vers != cc_credentials_v5 && + cred_vers != cc_credentials_v4_v5) + return ccErrBadCredentialsVersion; + + if (outCCachepp == NULL) + return ccErrBadParam; + + ccache = (cc_server_ccache_t*)malloc(sizeof(cc_server_ccache_t)); + if (ccache == NULL) + return ccErrNoMem; + + ccache->name = name; + ccache->principal_v4 = NULL; + ccache->principal_v5 = NULL; + ccache->changed = time(NULL); + ccache->kdc_offset = 0; + ccache->last_default = 0; + cci_generic_list_new(&ccache->active_iterators); + ccs_credentials_list_new(&ccache->creds); + ccache->is_default = 0; + ccache->kdc_set = 0; + ccache->versions = cred_vers; + ccache->mycontext = NULL; + + ccs_ccache_set_principal(ccache, cred_vers, principal); + *outCCachepp = ccache; + return ccNoError; +} + +/** + * ccs_ccache_check_version() + * + * Purpose: Check to see if the ccache and the creds have compatible versions. + * + * Return: ccNoError and compat = 1 if they are compatible + * ccNoError and compat = 0 if they are not compatible + * + * Errors: ccErrInvalidCCache - ccache is NULL + * ccErrBadParam - either creds or compat are NULL + */ +cc_int32 +ccs_ccache_check_version( const cc_server_ccache_t *ccache, + const cc_credentials_union* creds, + cc_uint32* compat) +{ + if (ccache == NULL) + return ccErrInvalidCCache; + + if (creds == NULL || compat == NULL) + return ccErrBadParam; + + if (ccache->versions == cc_credentials_v4_v5) + *compat = 1; + else if (ccache->versions == creds->version) + *compat = 1; + else + *compat = 0; + + return ccNoError; +} + +/** +ccs_ccache_check_principal() + +Check to see if the client principal from the credentials matches +the principal associated with the cache. + +* Return: ccNoError and compat = 1 if they are compatible +* ccNoError and compat = 0 if they are not compatible +* +* Errors: ccErrInvalidCCache - ccache is NULL +* ccErrBadParam - either creds or compat are NULL +* ccErrBadCredentialVersion - unsupported credential type +*/ +cc_int32 +ccs_ccache_check_principal( const cc_server_ccache_t *ccache, + const cc_credentials_union* creds, + cc_uint32* compat) +{ + if (ccache == NULL) + return ccErrInvalidCCache; + + if (creds == NULL || compat == NULL) + return ccErrBadParam; + + if (creds->version == cc_credentials_v4) { + if (strcmp(creds->credentials.credentials_v4->principal, ccache->principal_v4) == 0) + *compat = 1; + else + *compat = 0; + } else if (creds->version == cc_credentials_v5) { + if (strcmp(creds->credentials.credentials_v5->client, ccache->principal_v5) == 0) + *compat = 1; + else + *compat = 0; + } else { + return ccErrBadCredentialsVersion; + } + return ccNoError; +} + + +/** + * ccs_ccache_store_creds() + * + * Purpose: Stores the provided credentials into the provided cache. Validates the + * ability of the cache to store credentials of the given version and client + * principal. + * + * Return: 0 on success + * -1 on error + * + * Errors: ccErrNoMem + * ccErrBadCredentialsVersion + * ccErrBadInvalidCredentials + * ccErrInvalidCache + * ccErrBadParam + */ +cc_int32 +ccs_ccache_store_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials) +{ + cc_server_credentials_t* stored_cred=NULL; + cc_uint32 valid_version, valid_principal; + cc_int32 code; + + if (ccache == NULL) + return ccErrInvalidCCache; + + if (credentials == NULL) + return ccErrBadParam; + + code = ccs_ccache_check_version(ccache, credentials, &valid_version); + if (code != ccNoError) { + /* pass error on to caller */ + goto bad; + } + code = ccs_ccache_check_principal(ccache, credentials, &valid_principal); + if (code != ccNoError) { + /* pass error on to caller */ + goto bad; + } + if (valid_version && valid_principal) { + stored_cred = (cc_server_credentials_t*)malloc(sizeof(cc_server_credentials_t)); + if (stored_cred == NULL) { + code = ccErrNoMem; + goto bad; + } + memcpy(&stored_cred->creds, credentials, sizeof(cc_credentials_union)); + + if (credentials->version == cc_credentials_v4) { + stored_cred->creds.credentials.credentials_v4 = (cc_credentials_v4_t*)malloc(sizeof(cc_credentials_v4_t)); + if (stored_cred->creds.credentials.credentials_v4 == NULL) { + code = ccErrNoMem; + goto bad; + } + + memcpy(stored_cred->creds.credentials.credentials_v4, credentials->credentials.credentials_v4, sizeof(cc_credentials_v4_t)); + } else if (credentials->version == cc_credentials_v5) { + stored_cred->creds.credentials.credentials_v5 = (cc_credentials_v5_t*)malloc(sizeof(cc_credentials_v5_t)); + if (stored_cred->creds.credentials.credentials_v5 == NULL) { + code = ccErrNoMem; + goto bad; + } + + memcpy(stored_cred->creds.credentials.credentials_v5, credentials->credentials.credentials_v5, sizeof(cc_credentials_v5_t)); + } else { + code = ccErrBadCredentialsVersion; + goto bad; + } + + code = ccs_credentials_list_append(ccache->creds, stored_cred, NULL); + if ( code != ccNoError ) { + /* pass error on to caller */ + goto bad; + } + if (ccache->creds->head->data == (cc_uint8 *)stored_cred) + stored_cred->is_default = 1; /*we're first on the list, so we're default*/ + + ccs_ccache_changed(ccache); + return ccNoError; + } else { +#ifdef DEBUG + printf("vers: %d\tprincipal: %d\n", + valid_version, valid_principal); +#endif /* DEBUG */ + code = ccErrInvalidCredentials; + goto bad; + } + + bad: + if (stored_cred) + free(stored_cred); + return code; /* error */ +} + +/** + * ccs_ccache_changed() + * + * Purpose: Updates the last update time for the ccache and its associated context. + * Provides a location from which interested parties should be notified + * of cache updates. + * + * Return: none + * + * Errors: none + */ +void +ccs_ccache_changed(cc_server_ccache_t* ccache) +{ + ccache->changed = time(NULL); + if (ccache->mycontext != NULL) + ccache->mycontext->changed = time(NULL); + + /* XXX - notify registered listeners when implemented */ +} + +/** + * ccs_ccache_rem_creds() + * + * Purpose: Removes the specified credential object from the specified cache if + * it exists + * + * Return: 0 on success (credential is not in the cache) + * -1 on error + * + * Errors: ccErrBadParam, ccErrNoMem (from cc_credentials_list_iterator) + * + * Verify: does the memory associated with stored_cred->creds need to be freed? + * + */ +cc_int32 +ccs_ccache_rem_creds(cc_server_ccache_t *ccache, const cc_credentials_union* credentials) +{ + cc_credentials_iterate_t* credentials_iterator=NULL, *active; + cc_generic_iterate_t* generic_iterator=NULL; + cc_credentials_list_node_t* credentials_node; + cc_generic_list_node_t* generic_node; + cc_server_credentials_t* stored_cred; + cc_int8 changed = 0; + cc_int32 code = 0; + + if (ccache == NULL) + return ccErrInvalidCCache; + + if (credentials == NULL) + return ccErrBadParam; + + code = ccs_credentials_list_iterator(ccache->creds, &credentials_iterator); + if (code != ccNoError) { + /* pass error to caller */ + goto cleanup; + } + + while (ccs_credentials_iterate_has_next(credentials_iterator)) { + code = ccs_credentials_iterate_next(credentials_iterator, &credentials_node); + stored_cred = (cc_server_credentials_t*)credentials_node->data; + if (memcmp(&stored_cred->creds,credentials,sizeof(cc_credentials_union)) == 0) { + /* XXX - do we need to free(stored_cred->creds) ? */ + free(credentials_node->data); + changed = 1; + + /*If any iterator's next points to the deleted node, make it point to the next node*/ + code = cci_generic_list_iterator(ccache->active_iterators, &generic_iterator); + while (cci_generic_iterate_has_next(generic_iterator)) { + code = cci_generic_iterate_next(generic_iterator, &generic_node); + active = (cc_credentials_iterate_t*)generic_node->data; + if (active->next == credentials_node) + active->next = active->next->next; + } + code = cci_generic_free_iterator(generic_iterator); + generic_iterator = NULL; + + if (credentials_node == ccache->creds->head) { /*removing the default, must make next cred default*/ + code = ccs_credentials_list_remove_element(ccache->creds, credentials_node); + + if (ccache->creds->head != NULL) + ((cc_server_credentials_t*)ccache->creds->head->data)->is_default = 1; + } else { + code = ccs_credentials_list_remove_element(ccache->creds, credentials_node); + } + break; + } + } + + cleanup: + if (changed) + ccs_ccache_changed(ccache); + if (credentials_iterator) + ccs_credentials_free_iterator(credentials_iterator); + if (generic_iterator) + cci_generic_free_iterator(generic_iterator); + return code; +} + +/** + * ccs_ccache_move() + * + * Purpose: Destroys the existing contents of the destination and copies + * all credentials from the source to the destination + * + * Return: 0 on success + * -1 on error + * + * Errors: ccBadNoMem + * + */ + +cc_int32 +ccs_ccache_move(cc_server_ccache_t *source, cc_server_ccache_t* destination) +{ + cc_generic_list_node_t* node; + cc_generic_iterate_t* iterator; + cc_credentials_iterate_t* cur; + cc_int32 code; + + if (source == NULL || destination == NULL) + return ccErrBadParam; + + code = ccs_credentials_list_destroy(destination->creds); + if ( code != ccNoError ) + return code; + + code = ccs_credentials_list_copy(source->creds, &destination->creds); + if ( code != ccNoError ) + return code; + + destination->versions = source->versions; + destination->kdc_offset = source->kdc_offset; + destination->last_default = 0; + + /*reset all active iterators to point to the head of the new creds list*/ + if (destination->active_iterators->head != NULL) { + code = cci_generic_list_iterator(destination->active_iterators, &iterator); + while (cci_generic_iterate_has_next(iterator)) { + code = cci_generic_iterate_next(iterator, &node); + cur = (cc_credentials_iterate_t*)node->data; + cur->next = destination->creds->head; + } + code = cci_generic_free_iterator(iterator); + } + + ccs_ccache_changed(destination); + return code; +} + +/** + * ccs_ccache_get_kdc_time_offset() + * + * Purpose: Retrieves the kdc_time_offset from the ccache if set + * + * Return: 0 on success + * -1 on error + * + * Errors: ccErrBadParam, ccErrTimeOffsetNotSet + * + */ +cc_int32 +ccs_ccache_get_kdc_time_offset(cc_server_ccache_t* ccache, cc_time64* offset) +{ + if (ccache == NULL) + return ccErrInvalidCCache; + + if (offset == NULL) + return ccErrBadParam; + + if (!ccache->kdc_set) + return ccErrTimeOffsetNotSet; + + *offset = ccache->kdc_offset; + return ccNoError; +} + +/** + * ccs_ccache_set_kdc_time_offset() + * + * Purpose: Sets the kdc time offset in the designated ccache + * + * Return: 0 on success + * -1 on error + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_ccache_set_kdc_time_offset(cc_server_ccache_t* ccache, cc_time64 offset) +{ + if (ccache == NULL) + return ccErrInvalidCCache; + + ccache->kdc_offset = offset; + ccache->kdc_set = 1; + ccs_ccache_changed(ccache); + + return ccNoError; +} + +/** + * ccs_ccache_clear_kdc_time_offset() + * + * Purpose: Clear the kdc time offset in the designated ccache + * + * Return: 0 on success + * -1 on error + * + * Errors: ccErrBadParam + */ +cc_int32 +ccs_ccache_clear_kdc_time_offset(cc_server_ccache_t* ccache) +{ + if (ccache == NULL) + return ccErrInvalidCCache; + + ccache->kdc_offset = 0; + ccache->kdc_set = 0; + ccs_ccache_changed(ccache); + + return ccNoError; +} + +/** + * ccs_ccache_new_iterator() + * + * Purpose: Retrieve an iterator for the designated cache + * + * Return: 0 on success + * -1 on error + * + * Errors: ccErrBadParam, ccBadNoMem + */ +cc_int32 +ccs_ccache_new_iterator(cc_server_ccache_t* ccache, cc_credentials_iterate_t** iterator) +{ + cc_int32 code; + + if (ccache == NULL) + return ccErrInvalidCCache; + + if (iterator == NULL) + return ccErrBadParam; + + code = ccs_credentials_list_iterator(ccache->creds, iterator); + if (code != ccNoError) + return code; + + code = cci_generic_list_prepend(ccache->active_iterators, *iterator, sizeof(cc_credentials_iterate_t), NULL); + if (code != ccNoError) + return code; + + return ccNoError; +} + +/** + * ccs_ccache_get_principal() + * + * Purpose: Retrieves the client principal associated with the designated cache. + * The value is returned + * Return: + * + * Errors: + */ +cc_int32 +ccs_ccache_get_principal(cc_server_ccache_t* ccache, cc_int32 version, char ** principal) +{ + char *p = NULL; + + switch ( version ) { + case cc_credentials_v4: + p = ccache->principal_v4; + break; + case cc_credentials_v5: + p = ccache->principal_v5; + break; + default: + return ccErrBadCredentialsVersion; + } + + *principal = (char *)malloc(strlen(p)+1); + if ( *principal == NULL ) + return ccErrNoMem; + + strcpy(*principal, p); + return ccNoError; +} + +/** + * Purpose: Releases the memory associated with a ccache principal + * + * Return: + * + * Errors: + * + */ +cc_int32 +ccs_ccache_free_principal(char * principal) +{ + if ( principal == NULL ) + return ccErrBadParam; + + free(principal); + return ccNoError; +} + +/** + * ccache_set_principal() + * + * Purpose: Assigns a principal to the designated ccache and credential version. + * If the api version is 2, the cache is cleared of all existing + * credentials. + * + * Return: 0 on success + * -1 on error + * + * Errors: ccErrNoMem, ccErrBadCredentialsVersion + */ +cc_int32 +ccs_ccache_set_principal( cc_server_ccache_t* ccache, cc_int32 cred_version, + char* principal) +{ + cc_generic_iterate_t* generic_iterator; + cc_generic_list_node_t* generic_node; + cc_ccache_iterate_t* ccache_iterator; + cc_int32 code = ccNoError; + + if (ccache == NULL) + return ccErrInvalidCCache; + + if (principal == NULL) + return ccErrInvalidString; + + switch (cred_version) { + case cc_credentials_v4: + case cc_credentials_v4_v5: + ccache->principal_v4 = (char *)malloc(strlen(principal) + 1); + if (ccache->principal_v4 == NULL) + return ccErrNoMem; + strcpy(ccache->principal_v4, principal); + if (cred_version != cc_credentials_v4_v5) + break; + /* fall-through if we are v4_v5 */ + case cc_credentials_v5: + ccache->principal_v5 = (char *)malloc(strlen(principal) + 1); + if (ccache->principal_v5 == NULL) { + if (cred_version == cc_credentials_v4_v5) { + free(ccache->principal_v4); + ccache->principal_v4 = NULL; + } + return ccErrNoMem; + } + strcpy(ccache->principal_v5, principal); + break; + default: + return ccErrBadCredentialsVersion; + } + + /*For API version 2 clients set_principal implies a flush of all creds*/ + if (ccache->mycontext != NULL && ccache->mycontext->api_version == ccapi_version_2) { + ccs_credentials_list_destroy(ccache->creds); + ccs_credentials_list_new(&ccache->creds); + + /*clean up active_iterators*/ + code = cci_generic_list_iterator(ccache->active_iterators, &generic_iterator); + if (code == ccNoError) { + while (cci_generic_iterate_has_next(generic_iterator)) { + code = cci_generic_iterate_next(generic_iterator, &generic_node); + ccache_iterator = (cc_ccache_iterate_t*)generic_node->data; + ccache_iterator->next = NULL; + } + } + } + + ccs_ccache_changed(ccache); + + return code; +} + +/** + * ccs_ccache_destroy() + * + * Purpose: Destroys an existing ccache + * + * Return: 0 on success + * -1 on errors + * + * Errors: ccErrBadParam + */ +cc_int32 +ccs_ccache_destroy(cc_server_ccache_t* ccache) +{ + cc_int32 code; + + if ( ccache == NULL ) + return ccErrInvalidCCache; + + code = cci_generic_list_destroy(ccache->active_iterators); + code = ccs_credentials_list_destroy(ccache->creds); + + if (ccache->mycontext != NULL) + code = ccs_context_rem_ccache(ccache->mycontext, ccache); + + return code; +} + +/** + * ccs_ccache_compare() + * + * Purpose: Returns a boolean value indicating if two caches are identical + * Implemented as pointer equivalence. + * + * Return: 1 if TRUE + * 0 if FALSE + * + * Errors: No errors + */ +cc_int32 +ccs_ccache_compare(cc_server_ccache_t* ccache1, cc_server_ccache_t* ccache2, cc_uint32 *result) +{ + if ( ccache1 == NULL || ccache2 == NULL ) + return ccErrInvalidCCache; + + if (ccache1 == ccache2) + *result = 1; + else + *result = 0; + + return ccNoError; +} + diff --git a/src/lib/ccapi/server/context.c b/src/lib/ccapi/server/ccs_context.c similarity index 76% rename from src/lib/ccapi/server/context.c rename to src/lib/ccapi/server/ccs_context.c index f405a4defb..a168147940 100644 --- a/src/lib/ccapi/server/context.c +++ b/src/lib/ccapi/server/ccs_context.c @@ -1,325 +1,325 @@ -/* $Copyright: - * - * Copyright 2004 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 MIT 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. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* - * Functions to manipulate datastore layer contexts. - * - */ - -#include -#include -#include -#include - -#include "CredentialsCache.h" -#include "datastore.h" - -int cc_myversion = 5; -char cc_vendor[] = "MIT C lang CCache V5"; -char cc_default_ccache_name[] = "krb5cc"; - - -cc_int32 -cci_context_new( int api_version, cc_auth_info_t* auth_info, - cc_session_info_t* session_info, cc_server_context_t** outContextpp ) -{ - cc_server_context_t* ctx; - - if ( outContextpp == NULL ) - return ccErrBadParam; - - ctx = (cc_server_context_t*)malloc(sizeof(cc_server_context_t)); - if (ctx == NULL) - return ccErrNoMem; - - cci_ccache_list_new(&ctx->ccaches); - cci_generic_list_new(&ctx->active_iterators); - ctx->api_version = api_version; - ctx->auth_info = auth_info; - ctx->session_info = session_info; - ctx->changed = time(NULL); - - *outContextpp = ctx; - return ccNoError; -} - -cc_int32 -cci_context_get_default_ccache_name(cc_server_context_t* ctx, char ** outNamepp) -{ - cc_server_ccache_t* default_ccache; - - if (outNamepp == NULL) - return ccErrBadParam; - - if (ctx == NULL) - return ccErrInvalidContext; - - if (ctx->ccaches->head != NULL) { - default_ccache = (cc_server_ccache_t*)ctx->ccaches->head->data; - *outNamepp = default_ccache->name; - } else { - *outNamepp = cc_default_ccache_name; - } - return ccNoError; -} - - -cc_int32 -cci_context_find_ccache( cc_server_context_t* ctx, char *name, - cc_server_ccache_t** outCcachepp ) -{ - cc_ccache_iterate_t* ccache_iterator; - cc_ccache_list_node_t* ccache_node; - cc_server_ccache_t* ccache; - cc_int32 code; - - if (ctx == NULL) - return ccErrInvalidContext; - - if (name == NULL) - return ccErrInvalidString; - - if (outCcachepp == NULL) - return ccErrBadParam; - - code = cci_ccache_list_iterator(ctx->ccaches, &ccache_iterator); - while (cci_ccache_iterate_has_next(ccache_iterator)) { - code = cci_ccache_iterate_next(ccache_iterator, &ccache_node); - ccache = (cc_server_ccache_t *)ccache_node->data; - if (strcmp(ccache->name, name) == 0) { - free(ccache_iterator); - *outCcachepp = ccache; - return ccNoError; - } - } - free(ccache_iterator); - return ccErrCCacheNotFound; -} - -cc_int32 -cci_context_open_ccache( cc_server_context_t* ctx, char *name, - cc_server_ccache_t** outCcachepp ) -{ - return cci_context_find_ccache(ctx, name, outCcachepp); -} - - -cc_int32 -cci_context_create_ccache( cc_server_context_t* ctx, char *name, int creds_version, - char *principal, cc_server_ccache_t** outCcachepp ) -{ - cc_server_ccache_t* ccache; - cc_int32 code; - - if (ctx == NULL) - return ccErrInvalidContext; - - if (outCcachepp == NULL) - return ccErrBadParam; - - if (name == NULL || principal == NULL) - return ccErrInvalidString; - - if (creds_version != cc_credentials_v4 && creds_version != cc_credentials_v5 && - creds_version != cc_credentials_v4_v5) - return ccErrBadCredentialsVersion; - - code = cci_context_find_ccache(ctx, name, &ccache); - if (code == ccNoError) { - code = cci_ccache_set_principal(ccache, creds_version, principal); - } else { - code = cci_ccache_new(name, principal, creds_version, &ccache); - if (code != ccNoError) - return code; /*let caller deal with error*/ - - ccache->mycontext = ctx; - ctx->changed = time(NULL); - cci_ccache_list_append(ctx->ccaches, ccache, NULL); - - if (ctx->ccaches->head->data == (cc_uint8 *)ccache) { - ccache->is_default = 1; - } - } - *outCcachepp = ccache; - return ccNoError; -} - -cc_int32 -cci_context_create_default_ccache( cc_server_context_t* ctx, int creds_version, - char *principal, cc_server_ccache_t** outCcachepp ) -{ - cc_server_ccache_t* ccache, *old_default; - cc_int32 code; - - if (ctx == NULL) - return ccErrInvalidContext; - - if (outCcachepp == NULL) - return ccErrBadParam; - - if (principal == NULL) - return ccErrInvalidString; - - if (creds_version != cc_credentials_v4 && creds_version != cc_credentials_v5 && - creds_version != cc_credentials_v4_v5) - return ccErrBadCredentialsVersion; - - code = cci_context_find_ccache(ctx, cc_default_ccache_name, &ccache); - if (code == ccNoError) { - cci_ccache_set_principal(ccache, creds_version, principal); - } else { - code = cci_ccache_new(cc_default_ccache_name, principal, creds_version, &ccache); - if (code != ccNoError) - return code; /*let caller deal with error*/ - - ccache->mycontext = ctx; - ccache->is_default = 1; - ctx->changed = time(NULL); - - if (ctx->ccaches->head != NULL) { - old_default = (cc_server_ccache_t *)ctx->ccaches->head->data; - old_default->is_default = 0; - old_default->last_default = time(NULL); - } - - cci_ccache_list_prepend(ctx->ccaches, ccache, NULL); - } - *outCcachepp = ccache; - return ccNoError; -} - -cc_int32 -cci_context_ccache_iterator(cc_server_context_t* ctx, cc_ccache_iterate_t** iterpp) -{ - cc_ccache_iterate_t* ccache_iterator; - cc_int32 code; - - if (ctx == NULL) - return ccErrInvalidContext; - - if (iterpp == NULL) - return ccErrBadParam; - - code = cci_ccache_list_iterator(ctx->ccaches, &ccache_iterator); - if (code != ccNoError) - return code; - cci_generic_list_prepend(ctx->active_iterators, ccache_iterator, sizeof(cc_ccache_iterate_t), NULL); - - *iterpp = ccache_iterator; - return ccNoError; -} - -cc_int32 -cci_context_compare(cc_server_context_t* a, cc_server_context_t* b) -{ - if (a == b) - return 1; - else - return 0; -} - -cc_int32 -cci_context_destroy(cc_server_context_t* ctx) -{ - cc_ccache_iterate_t* ccache_iterator; - cc_ccache_list_node_t* ccache_node; - cc_server_ccache_t* ccache; - cc_int32 code; - - if (ctx == NULL) - return ccErrInvalidContext; - - cci_generic_list_destroy(ctx->active_iterators); - - code = cci_ccache_list_iterator(ctx->ccaches, &ccache_iterator); - while (cci_ccache_iterate_has_next(ccache_iterator)) { - code = cci_ccache_iterate_next(ccache_iterator, &ccache_node); - ccache = (cc_server_ccache_t *)ccache_node->data; - ccache_node->data = NULL; - cci_ccache_destroy(ccache); - } - cci_ccache_list_destroy(ctx->ccaches); - - return ccNoError; -} - -cc_int32 -cci_context_rem_ccache(cc_server_context_t* ctx, cc_server_ccache_t* ccache) -{ - cc_ccache_iterate_t* ccache_iterator; - cc_ccache_iterate_t* active_ccache_iterator; - cc_ccache_list_node_t* ccache_node; - cc_server_ccache_t* list_ccache; - cc_generic_list_node_t* gen_node; - cc_generic_iterate_t* gen_iterator; - cc_int32 code; - - if (ctx == NULL) - return ccErrInvalidContext; - - if (ccache == NULL) - return ccErrInvalidCCache; - - code = cci_ccache_list_iterator(ctx->ccaches, &ccache_iterator); - while (cci_ccache_iterate_has_next(ccache_iterator)) { - code = cci_ccache_iterate_next(ccache_iterator, &ccache_node); - list_ccache = (cc_server_ccache_t *)ccache_node->data; - - if (list_ccache == ccache) { - code = cci_generic_list_iterator(ctx->active_iterators, &gen_iterator); - while (cci_generic_iterate_has_next(gen_iterator)) { - code = cci_generic_iterate_next(gen_iterator, &gen_node); - active_ccache_iterator = (cc_server_ccache_t *)gen_node->data; - if (active_ccache_iterator->next == ccache_node) { - active_ccache_iterator->next = active_ccache_iterator->next->next; - } - } - free(gen_iterator); - code = cci_ccache_list_remove_element(ctx->ccaches, ccache_node); - break; - } - } - free(ccache_iterator); - return ccNoError; -} - +/* $Copyright: + * + * Copyright 2004-2006 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 MIT 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. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Individual source code files are copyright MIT, Cygnus Support, + * OpenVision, Oracle, Sun Soft, FundsXpress, and others. + * + * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, + * and Zephyr are trademarks of the Massachusetts Institute of Technology + * (MIT). No commercial use of these trademarks may be made without prior + * written permission of MIT. + * + * "Commercial use" means use of a name in a product or other for-profit + * manner. It does NOT prevent a commercial firm from referring to the MIT + * trademarks in order to convey information (although in doing so, + * recognition of their trademark status should be given). + * $ + */ + +/* + * Functions to manipulate datastore layer contexts. + * + */ + +#include +#include +#include +#include + +#include "CredentialsCache.h" +#include "datastore.h" + +int cc_myversion = 5; +char cc_vendor[] = "MIT C lang CCache V5"; +char cc_default_ccache_name[] = "krb5cc"; + + +cc_int32 +ccs_context_new( int api_version, cc_auth_info_t* auth_info, + cc_session_info_t* session_info, cc_server_context_t** outContextpp ) +{ + cc_server_context_t* ctx; + + if ( outContextpp == NULL ) + return ccErrBadParam; + + ctx = (cc_server_context_t*)malloc(sizeof(cc_server_context_t)); + if (ctx == NULL) + return ccErrNoMem; + + ccs_ccache_list_new(&ctx->ccaches); + cci_generic_list_new(&ctx->active_iterators); + ctx->api_version = api_version; + ctx->auth_info = auth_info; + ctx->session_info = session_info; + ctx->changed = time(NULL); + + *outContextpp = ctx; + return ccNoError; +} + +cc_int32 +ccs_context_get_default_ccache_name(cc_server_context_t* ctx, char ** outNamepp) +{ + cc_server_ccache_t* default_ccache; + + if (outNamepp == NULL) + return ccErrBadParam; + + if (ctx == NULL) + return ccErrInvalidContext; + + if (ctx->ccaches->head != NULL) { + default_ccache = (cc_server_ccache_t*)ctx->ccaches->head->data; + *outNamepp = default_ccache->name; + } else { + *outNamepp = cc_default_ccache_name; + } + return ccNoError; +} + + +cc_int32 +ccs_context_find_ccache( cc_server_context_t* ctx, char *name, + cc_server_ccache_t** outCcachepp ) +{ + cc_ccache_iterate_t* ccache_iterator; + cc_ccache_list_node_t* ccache_node; + cc_server_ccache_t* ccache; + cc_int32 code; + + if (ctx == NULL) + return ccErrInvalidContext; + + if (name == NULL) + return ccErrInvalidString; + + if (outCcachepp == NULL) + return ccErrBadParam; + + code = ccs_ccache_list_iterator(ctx->ccaches, &ccache_iterator); + while (ccs_ccache_iterate_has_next(ccache_iterator)) { + code = ccs_ccache_iterate_next(ccache_iterator, &ccache_node); + ccache = (cc_server_ccache_t *)ccache_node->data; + if (strcmp(ccache->name, name) == 0) { + free(ccache_iterator); + *outCcachepp = ccache; + return ccNoError; + } + } + free(ccache_iterator); + return ccErrCCacheNotFound; +} + +cc_int32 +ccs_context_open_ccache( cc_server_context_t* ctx, char *name, + cc_server_ccache_t** outCcachepp ) +{ + return ccs_context_find_ccache(ctx, name, outCcachepp); +} + + +cc_int32 +ccs_context_create_ccache( cc_server_context_t* ctx, char *name, int creds_version, + char *principal, cc_server_ccache_t** outCcachepp ) +{ + cc_server_ccache_t* ccache; + cc_int32 code; + + if (ctx == NULL) + return ccErrInvalidContext; + + if (outCcachepp == NULL) + return ccErrBadParam; + + if (name == NULL || principal == NULL) + return ccErrInvalidString; + + if (creds_version != cc_credentials_v4 && creds_version != cc_credentials_v5 && + creds_version != cc_credentials_v4_v5) + return ccErrBadCredentialsVersion; + + code = ccs_context_find_ccache(ctx, name, &ccache); + if (code == ccNoError) { + code = ccs_ccache_set_principal(ccache, creds_version, principal); + } else { + code = ccs_ccache_new(name, principal, creds_version, &ccache); + if (code != ccNoError) + return code; /*let caller deal with error*/ + + ccache->mycontext = ctx; + ctx->changed = time(NULL); + ccs_ccache_list_append(ctx->ccaches, ccache, NULL); + + if (ctx->ccaches->head->data == (cc_uint8 *)ccache) { + ccache->is_default = 1; + } + } + *outCcachepp = ccache; + return ccNoError; +} + +cc_int32 +ccs_context_create_default_ccache( cc_server_context_t* ctx, int creds_version, + char *principal, cc_server_ccache_t** outCcachepp ) +{ + cc_server_ccache_t* ccache, *old_default; + cc_int32 code; + + if (ctx == NULL) + return ccErrInvalidContext; + + if (outCcachepp == NULL) + return ccErrBadParam; + + if (principal == NULL) + return ccErrInvalidString; + + if (creds_version != cc_credentials_v4 && creds_version != cc_credentials_v5 && + creds_version != cc_credentials_v4_v5) + return ccErrBadCredentialsVersion; + + code = ccs_context_find_ccache(ctx, cc_default_ccache_name, &ccache); + if (code == ccNoError) { + ccs_ccache_set_principal(ccache, creds_version, principal); + } else { + code = ccs_ccache_new(cc_default_ccache_name, principal, creds_version, &ccache); + if (code != ccNoError) + return code; /*let caller deal with error*/ + + ccache->mycontext = ctx; + ccache->is_default = 1; + ctx->changed = time(NULL); + + if (ctx->ccaches->head != NULL) { + old_default = (cc_server_ccache_t *)ctx->ccaches->head->data; + old_default->is_default = 0; + old_default->last_default = time(NULL); + } + + ccs_ccache_list_prepend(ctx->ccaches, ccache, NULL); + } + *outCcachepp = ccache; + return ccNoError; +} + +cc_int32 +ccs_context_ccache_iterator(cc_server_context_t* ctx, cc_ccache_iterate_t** iterpp) +{ + cc_ccache_iterate_t* ccache_iterator; + cc_int32 code; + + if (ctx == NULL) + return ccErrInvalidContext; + + if (iterpp == NULL) + return ccErrBadParam; + + code = ccs_ccache_list_iterator(ctx->ccaches, &ccache_iterator); + if (code != ccNoError) + return code; + cci_generic_list_prepend(ctx->active_iterators, ccache_iterator, sizeof(cc_ccache_iterate_t), NULL); + + *iterpp = ccache_iterator; + return ccNoError; +} + +cc_int32 +ccs_context_compare(cc_server_context_t* a, cc_server_context_t* b) +{ + if (a == b) + return 1; + else + return 0; +} + +cc_int32 +ccs_context_destroy(cc_server_context_t* ctx) +{ + cc_ccache_iterate_t* ccache_iterator; + cc_ccache_list_node_t* ccache_node; + cc_server_ccache_t* ccache; + cc_int32 code; + + if (ctx == NULL) + return ccErrInvalidContext; + + cci_generic_list_destroy(ctx->active_iterators); + + code = ccs_ccache_list_iterator(ctx->ccaches, &ccache_iterator); + while (ccs_ccache_iterate_has_next(ccache_iterator)) { + code = ccs_ccache_iterate_next(ccache_iterator, &ccache_node); + ccache = (cc_server_ccache_t *)ccache_node->data; + ccache_node->data = NULL; + ccs_ccache_destroy(ccache); + } + ccs_ccache_list_destroy(ctx->ccaches); + + return ccNoError; +} + +cc_int32 +ccs_context_rem_ccache(cc_server_context_t* ctx, cc_server_ccache_t* ccache) +{ + cc_ccache_iterate_t* ccache_iterator; + cc_ccache_iterate_t* active_ccache_iterator; + cc_ccache_list_node_t* ccache_node; + cc_server_ccache_t* list_ccache; + cc_generic_list_node_t* gen_node; + cc_generic_iterate_t* gen_iterator; + cc_int32 code; + + if (ctx == NULL) + return ccErrInvalidContext; + + if (ccache == NULL) + return ccErrInvalidCCache; + + code = ccs_ccache_list_iterator(ctx->ccaches, &ccache_iterator); + while (ccs_ccache_iterate_has_next(ccache_iterator)) { + code = ccs_ccache_iterate_next(ccache_iterator, &ccache_node); + list_ccache = (cc_server_ccache_t *)ccache_node->data; + + if (list_ccache == ccache) { + code = cci_generic_list_iterator(ctx->active_iterators, &gen_iterator); + while (cci_generic_iterate_has_next(gen_iterator)) { + code = cci_generic_iterate_next(gen_iterator, &gen_node); + active_ccache_iterator = (cc_ccache_iterate_t *)gen_node->data; + if (active_ccache_iterator->next == ccache_node) { + active_ccache_iterator->next = active_ccache_iterator->next->next; + } + } + free(gen_iterator); + code = ccs_ccache_list_remove_element(ctx->ccaches, ccache_node); + break; + } + } + free(ccache_iterator); + return ccNoError; +} + diff --git a/src/lib/ccapi/server/lists.c b/src/lib/ccapi/server/ccs_lists.c similarity index 56% rename from src/lib/ccapi/server/lists.c rename to src/lib/ccapi/server/ccs_lists.c index 882ecb7a06..779c17b7a0 100644 --- a/src/lib/ccapi/server/lists.c +++ b/src/lib/ccapi/server/ccs_lists.c @@ -1,996 +1,657 @@ -/* $Copyright: - * - * Copyright 2004 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 MIT 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. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - - -/* - * Lists implementation. - * - */ - -#include -#include -#include - -#include "CredentialsCache.h" -#include "datastore.h" - -/** - * cci_generic_iterate_has_next() - * - * Purpose: Determine if an iterator has a next element - * - * Return: 1 if another element exists - * 0 if no additional elements exist - * - * Errors: None - * - */ -cc_int32 -cci_generic_iterate_has_next(cc_generic_iterate_t *iterate) -{ - return ((iterate == NULL || iterate->next == NULL) ? 0 : 1); -} - -/** - * cci_generic_iterate_next() - * - * Purpose: Retrieve the next element from an iterator and advance - * the iterator - * - * Return: non-NULL, the next element in the iterator - * NULL, the iterator list is empty or iterator is invalid - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_generic_iterate_next(cc_generic_iterate_t *iterator, cc_generic_list_node_t** nodepp) -{ - cc_generic_list_node_t* ret; - - if (iterator == NULL || nodepp == NULL) - return ccErrBadParam; - - ret = iterator->next; - if (iterator->next != NULL) - iterator->next = iterator->next->next; - - *nodepp = ret; - return ccNoError; -} - -/** - * cci_context_iterate_has_next() - * - * Purpose: Determine if a context iterator has a next element - * - * Return: 1 if another element exists - * 0 if no additional elements exist - */ -cc_int32 -cci_context_iterate_has_next(cc_context_iterate_t *iterate) -{ - if ( iterate == NULL ) - return 0; - - return cci_generic_iterate_has_next((cc_generic_iterate_t*)iterate); -} - -/** - * cci_context_iterate_next() - * - * Purpose: Retrieve the next element from a context iterator and advance - * the iterator - * - * Return: non-NULL, the next element in the iterator - * NULL, the iterator list is empty or iterator is invalid - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_context_iterate_next(cc_context_iterate_t *iterate, cc_context_list_node_t ** nodepp) -{ - if ( iterate == NULL || nodepp == NULL) - return ccErrBadParam; - - return cci_generic_iterate_next((cc_generic_iterate_t*)iterate,(cc_context_list_node_t**)nodepp); -} - -/** - * cci_ccache_iterate_has_next() - * - * Purpose: Determine if a cache iterator has a next element - * - * Return: 1 if another element exists - * 0 if no additional elements exist - * -1 if error - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_ccache_iterate_has_next(cc_ccache_iterate_t *iterate) -{ - if ( iterate == NULL ) - return 0; - return cci_generic_iterate_has_next((cc_generic_iterate_t*)iterate); -} - -/** - * cci_ccache_iterate_next() - * - * Purpose: Retrieve the next element from a ccache iterator and advance - * the iterator - * - * Return: non-NULL, the next element in the iterator - * NULL, the iterator list is empty or iterator is invalid - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_ccache_iterate_next(cc_ccache_iterate_t *iterate, cc_ccache_list_node_t ** nodepp) -{ - if ( iterate == NULL || nodepp == NULL) - return ccErrBadParam; - - return cci_generic_iterate_next((cc_generic_iterate_t*)iterate, (cc_ccache_list_node_t**)nodepp); -} - -/** - * cci_credentials_iterate_has_next() - * - * Purpose: Determine if a credentials iterator has a next element - * - * Return: 1 if another element exists - * 0 if no additional elements exist - * -1 if error - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_credentials_iterate_has_next(cc_credentials_iterate_t *iterate) -{ - if ( iterate == NULL ) - return 0; - - return cci_generic_iterate_has_next((cc_generic_iterate_t*)iterate); -} - -/** - * cci_credentials_iterate_next() - * - * Purpose: Retrieve the next element from a credentials iterator and advance - * the iterator - * - * Return: non-NULL, the next element in the iterator - * NULL, the iterator list is empty or iterator is invalid - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_credentials_iterate_next(cc_credentials_iterate_t *iterate, cc_credentials_list_node_t** nodepp) -{ - if ( iterate == NULL || nodepp == NULL ) - return ccErrBadParam; - return cci_generic_iterate_next((cc_generic_iterate_t*)iterate, (cc_credentials_list_node_t**)nodepp); -} - -/** - * cci_generic_list_new() - * - * Purpose: Allocate new generic list - * - * Return: non-NULL, an empty list - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_generic_list_new(cc_generic_list_head_t ** listpp) -{ - cc_generic_list_head_t* ret = (cc_generic_list_head_t *)malloc(sizeof(cc_generic_list_head_t)); - if (ret == NULL) - return ccErrNoMem; - - ret->type = generic; - ret->head = ret->tail = NULL; - *listpp = ret; - - return ccNoError; -} - -/** - * cci_generic_list_append() - * - * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_generic_list_append(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t** nodepp) -{ - cc_generic_list_node_t* new_node; - - if ( data == NULL || len == 0 ) - return ccErrBadParam; - - new_node = (cc_generic_list_node_t *)malloc(sizeof(cc_generic_list_node_t)); - if (new_node == NULL) - return ccErrNoMem; - - new_node->data = malloc(len); - if ( new_node->data == NULL ) { - free(new_node); - return ccErrNoMem; - } - - memcpy(new_node->data,data,len); - new_node->len = len; - - if (head->head == NULL) { /*empty list*/ - head->head = new_node; - head->tail = new_node; - new_node->next = new_node->prev = NULL; - } else { - new_node->prev = head->tail; - head->tail->next = new_node; - head->tail = new_node; - new_node->next = NULL; - } - if (nodepp != NULL) - *nodepp = new_node; - return ccNoError; -} - -/** - * cci_generic_list_prepend() - * - * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem, ccErrBadParam - * - */ -cc_int32 -cci_generic_list_prepend(cc_generic_list_head_t *head, void *data, cc_uint32 len, cc_generic_list_node_t** nodepp) -{ - cc_generic_list_node_t* new_node; - - if ( data == NULL || len == 0 ) - return ccErrBadParam; - - new_node = (cc_generic_list_node_t *)malloc(sizeof(cc_generic_list_node_t)); - if (new_node == NULL) - return ccErrNoMem; - - new_node->data = malloc(len); - if ( new_node->data == NULL ) { - free(new_node); - return ccErrNoMem; - } - - memcpy(new_node->data,data,len); - new_node->len = len; - - if (head->head == NULL) { /*empty list*/ - head->head = new_node; - head->tail = new_node; - new_node->prev = new_node->next = NULL; - } else { - new_node->next = head->head; - head->head->prev = new_node; - new_node->prev = NULL; - head->head = new_node; - } - - if (nodepp != NULL) - *nodepp = new_node; - - return ccNoError; -} - -/** - * cci_generic_list_remove_element() - * - * Purpose: Remove a node from the list - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_generic_list_remove_element(cc_generic_list_head_t* head, cc_generic_list_node_t* rem) -{ - if (head->head == NULL || rem == NULL) - return ccErrBadParam; - - if (head->head == rem && head->tail == rem) { /*removing only element of list*/ - head->head = head->tail = NULL; - } else if (head->head == rem) { /*removing head*/ - head->head = head->head->next; - } else if (head->tail == rem) { /*removing tail*/ - head->tail = head->tail->prev; - head->tail->next = NULL; - } else { - rem->prev->next = rem->next; - rem->next->prev = rem->prev; - } - free(rem); - return ccNoError; -} - -/** - * cci_generic_free_element() - * - * Purpose: Free the memory associated with a node - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_generic_free_element(cc_generic_list_node_t* node) -{ - if ( node == NULL ) - return ccErrBadParam; - - if ( node->data ) { - free(node->data); - node->data = NULL; - } - node->len = 0; - node->next = node->prev = NULL; - free(node); - return ccNoError; -} - - -/** - * cci_generic_list_destroy() - * - * Purpose: Deallocate a list and all of its contents - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_generic_list_destroy(cc_generic_list_head_t* head) -{ - cc_generic_list_node_t *cur, *next; - cc_int32 ret = ccNoError; - - if ( head == NULL ) - return ccErrBadParam; - - for (cur = head->head; ret == ccNoError && cur != NULL; cur = next) { - next = cur->next; - ret = cci_generic_free_element(cur); - } - free(head); - return(ret); -} - -/** - * cci_context_list_destroy() - * - * Purpose: Deallocate a list and all of its contents - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_context_list_destroy(cc_context_list_head_t* head) -{ - return cci_generic_list_destroy((cc_generic_list_head_t*)head); -} - -/** - * cci_ccache_list_destroy() - * - * Purpose: Deallocate a list and all of its contents - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_ccache_list_destroy(cc_ccache_list_head_t* head) -{ - return cci_generic_list_destroy((cc_generic_list_head_t*)head); -} - -/** - * cci_credentials_list_destroy() - * - * Purpose: Deallocate a list and all of its contents - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_credentials_list_destroy(cc_credentials_list_head_t* head) -{ - return cci_generic_list_destroy((cc_generic_list_head_t*)head); -} - -/** - * cci_generic_list_copy() - * - * Purpose: Copy a list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrBadParam, ccErrNoMem - * - */ -cc_int32 -cci_generic_list_copy(cc_generic_list_head_t* head, cc_generic_list_head_t** headpp) -{ - cc_generic_list_head_t* copy; - cc_generic_list_node_t *src_node, *dst_node; - cc_int32 code; - - if (head == NULL || headpp == NULL) - return ccErrBadParam; - - code = cci_generic_list_new(©); - if (code != ccNoError) - return code; - - for (src_node = head->head; src_node != NULL; src_node = src_node->next) { - code = cci_generic_list_append(copy, src_node->data, src_node->len, &dst_node); - if (code != ccNoError) { - cci_generic_list_destroy(copy); - return code; - } - } - *headpp = copy; - return ccNoError; -} - -/** - * cci_context_list_copy() - * - * Purpose: Copy a list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrBadParam, ccErrNoMem - * - */ -cc_int32 -cci_context_list_copy(cc_context_list_head_t* head, cc_context_list_head_t** headpp ) -{ - return cci_generic_list_copy((cc_generic_list_head_t*)head, (cc_context_list_head_t **)headpp); -} - -/** - * cci_ccache_list_copy() - * - * Purpose: Copy a list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrBadParam, ccErrNoMem - */ -cc_int32 -cci_ccache_list_copy(cc_ccache_list_head_t* head, cc_ccache_list_head_t** headpp) -{ - return cci_generic_list_copy((cc_generic_list_head_t*)head, (cc_ccache_list_head_t **)headpp); -} - -/** - * cci_credentials_list_copy() - * - * Purpose: Copy a list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrBadParam, ccErrNoMem - * - */ -cc_int32 -cci_credentials_list_copy(cc_credentials_list_head_t* head, cc_credentials_list_head_t** headpp) -{ - return cci_generic_list_copy((cc_generic_list_head_t*)head, (cc_credentials_list_head_t **)headpp); -} - - -/** - * cci_generic_list_iterator() - * - * Purpose: Allocate an iterator for the specified list - * - * Return: non-NULL, an iterator - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_generic_list_iterator(cc_generic_list_head_t *head, cc_generic_iterate_t** headpp) -{ - cc_generic_iterate_t* iterator; - - if ( head == NULL || headpp == NULL ) - return ccErrBadParam; - - iterator = (cc_generic_iterate_t*)malloc(sizeof(cc_generic_iterate_t)); - if (iterator == NULL) - return ccErrNoMem; - - iterator->next = head->head; - *headpp = iterator; - return ccNoError; -} - -/** - * cci_generic_free_iterator() - * - * Purpose: Deallocate memory associated with an iterator - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_generic_free_iterator(cc_generic_iterate_t* iterator) -{ - if ( iterator == NULL ) - return ccErrBadParam; - - iterator->next = NULL; - free(iterator); - return ccNoError; -} - - -/** - * cci_context_list_new() - * - * Purpose: Allocate a new context list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_context_list_new(cc_context_list_head_t ** headpp) -{ - cc_context_list_head_t *ret; - - if ( headpp == NULL ) - return ccErrBadParam; - - ret = (cc_context_list_head_t *)malloc(sizeof(cc_context_list_head_t)); - if (ret == NULL) - return ccErrNoMem; - ret->head = ret->tail = NULL; - *headpp = ret; - return ccNoError; -} - -/** - * cci_context_list_append() - * - * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_context_list_append(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t** nodepp) -{ - return cci_generic_list_append((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_context_t), (cc_context_list_node_t**)nodepp); -} - -/** - * cci_context_list_prepend() - * - * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_context_list_prepend(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t** nodepp ) -{ - return cci_generic_list_prepend((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_context_t), (cc_context_list_node_t**)nodepp); -} - -/** - * cci_context_list_remove_element - * - * Purpose: Remove a node from the list - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - */ -cc_int32 -cci_context_list_remove_element(cc_context_list_head_t* head, cc_context_list_node_t* rem) -{ - return cci_generic_list_remove_element((cc_generic_list_head_t*)head, (cc_generic_list_node_t*)rem); -} - -/** - * cci_context_list_iterator() - * - * Purpose: Allocate an iterator for the specified list - * - * Return: non-NULL, an iterator - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_context_list_iterator(cc_context_list_head_t *head, cc_context_iterate_t** iterpp) -{ - cc_context_iterate_t* iterator; - - if ( head == NULL || iterpp == NULL ) - return ccErrBadParam; - - iterator = (cc_context_iterate_t*)malloc(sizeof(cc_context_iterate_t)); - if (iterator == NULL) - return ccErrNoMem; - - iterator->next = head->head; - *iterpp = iterator; - return ccNoError; -} - -/** - * cci_context_free_iterator() - * - * Purpose: Deallocate memory associated with an iterator - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_context_free_iterator(cc_context_iterate_t* iterator) -{ - if ( iterator == NULL ) - return ccErrBadParam; - - iterator->next = NULL; - free(iterator); - return ccNoError; -} - -/** - * cci_ccache_list_new() - * - * Purpose: Allocate a new ccache list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrNoMem - */ -cc_int32 -cci_ccache_list_new(cc_ccache_list_head_t ** listpp) -{ - cc_ccache_list_head_t *ret; - - if ( listpp == NULL ) - return ccErrBadParam; - - ret = (cc_ccache_list_head_t *)malloc(sizeof(cc_ccache_list_head_t)); - if (ret == NULL) - return ccErrNoMem; - - ret->head = ret->tail = NULL; - *listpp = ret; - return ccNoError; -} - -/** - * cci_ccache_list_append() - * - * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_ccache_list_append(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t** nodepp) -{ - return cci_generic_list_append((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_ccache_t), (cc_ccache_list_node_t**)nodepp); -} - -/** - * cci_ccache_list_prepend() - * - * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_ccache_list_prepend(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t** nodepp) -{ - return cci_generic_list_prepend((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_ccache_t), (cc_ccache_list_node_t**)nodepp); -} - -/** - * cci_ccache_list_remove_element() - * - * Purpose: Remove a node from the list - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_ccache_list_remove_element(cc_ccache_list_head_t* head, cc_ccache_list_node_t* rem) -{ - return cci_generic_list_remove_element((cc_generic_list_head_t*)head, (cc_generic_list_node_t*)rem); -} - -/** - * cci_ccache_list_iterator() - * - * Purpose: Allocate an iterator for the specified list - * - * Return: non-NULL, an iterator - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_ccache_list_iterator(cc_ccache_list_head_t *head, cc_ccache_iterate_t** iterpp) -{ - cc_ccache_iterate_t* iterator; - - if ( head == NULL || iterpp == NULL ) - return ccErrBadParam; - - iterator = (cc_ccache_iterate_t*)malloc(sizeof(cc_ccache_iterate_t)); - if (iterator == NULL) - return ccErrNoMem; - - iterator->next = head->head; - *iterpp = iterator; - return ccNoError; -} - -/** - * cci_ccache_free_iterator() - * - * Purpose: Deallocate memory associated with an iterator - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_ccache_free_iterator(cc_ccache_iterate_t* iterator) -{ - if ( iterator == NULL ) - return ccErrBadParam; - - iterator->next = NULL; - free(iterator); - return ccNoError; -} - -/** - * cci_credentials_list_new() - * - * Purpose: Allocate a new ccache list - * - * Return: non-NULL, a new list - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_credentials_list_new(cc_credentials_list_head_t ** list) -{ - if ( list == NULL ) - return ccErrBadParam; - - *list = (cc_credentials_list_head_t *)malloc(sizeof(cc_credentials_list_head_t)); - if (*list == NULL) - return ccErrNoMem; - - (*list)->head = (*list)->tail = NULL; - return ccNoError; -} - -/** - * cci_credentials_list_append() - * - * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_credentials_list_append(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t** nodepp ) -{ - return cci_generic_list_append((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_credentials_t), (cc_credentials_list_node_t**)nodepp); -} - -/** - * cci_credentials_list_prepend() - * - * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' - * - * Return: non-NULL, a pointer to the newly allocated node - * NULL, failure - * - * Errors: ccErrNoMem,ccErrBadParam - * - */ -cc_int32 -cci_credentials_list_prepend(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t** nodepp) -{ - return cci_generic_list_prepend((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_credentials_t), (cc_credentials_list_node_t**)nodepp); -} - -/** - * cci_credentials_list_remove_element() - * - * Purpose: Remove a node from the list - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_credentials_list_remove_element(cc_credentials_list_head_t* head, cc_credentials_list_node_t* rem) -{ - return cci_generic_list_remove_element((cc_generic_list_head_t*)head, (cc_generic_list_node_t*)rem); -} - -/** - * cci_credentials_list_iterator() - * - * Purpose: Allocate an iterator for the specified list - * - * Return: non-NULL, an iterator - * NULL, failure - * - * Errors: ccErrNoMem - * - */ -cc_int32 -cci_credentials_list_iterator(cc_credentials_list_head_t *head, cc_credentials_iterate_t** iterpp) -{ - cc_credentials_iterate_t* iterator; - - if ( head == NULL || iterpp == NULL ) - return ccErrBadParam; - - iterator = (cc_credentials_iterate_t*)malloc(sizeof(cc_credentials_iterate_t)); - if (iterator == NULL) - return ccErrNoMem; - - iterator->next = head->head; - *iterpp = iterator; - return ccNoError; -} - -/** - * cci_credentials_free_iterator() - * - * Purpose: Deallocate memory associated with an iterator - * - * Return: 0, success - * -1, failure - * - * Errors: ccErrBadParam - * - */ -cc_int32 -cci_credentials_free_iterator(cc_credentials_iterate_t* iterator) -{ - if ( iterator == NULL ) - return ccErrBadParam; - - iterator->next = NULL; - free(iterator); - return ccNoError; -} - +/* $Copyright: + * + * Copyright 2004-2006 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 MIT 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. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * Individual source code files are copyright MIT, Cygnus Support, + * OpenVision, Oracle, Sun Soft, FundsXpress, and others. + * + * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, + * and Zephyr are trademarks of the Massachusetts Institute of Technology + * (MIT). No commercial use of these trademarks may be made without prior + * written permission of MIT. + * + * "Commercial use" means use of a name in a product or other for-profit + * manner. It does NOT prevent a commercial firm from referring to the MIT + * trademarks in order to convey information (although in doing so, + * recognition of their trademark status should be given). + * $ + */ + + +/* + * Lists implementation. + * + */ + +#include +#include +#include + +#include "CredentialsCache.h" +#include "datastore.h" + +/** + * ccs_context_iterate_has_next() + * + * Purpose: Determine if a context iterator has a next element + * + * Return: 1 if another element exists + * 0 if no additional elements exist + */ +cc_int32 +ccs_context_iterate_has_next(cc_context_iterate_t *iterate) +{ + if ( iterate == NULL ) + return 0; + + return cci_generic_iterate_has_next((cc_generic_iterate_t*)iterate); +} + +/** + * ccs_context_iterate_next() + * + * Purpose: Retrieve the next element from a context iterator and advance + * the iterator + * + * Return: non-NULL, the next element in the iterator + * NULL, the iterator list is empty or iterator is invalid + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_context_iterate_next(cc_context_iterate_t *iterate, cc_context_list_node_t ** nodepp) +{ + if ( iterate == NULL || nodepp == NULL) + return ccErrBadParam; + + return cci_generic_iterate_next((cc_generic_iterate_t*)iterate,(cc_context_list_node_t**)nodepp); +} + +/** + * ccs_ccache_iterate_has_next() + * + * Purpose: Determine if a cache iterator has a next element + * + * Return: 1 if another element exists + * 0 if no additional elements exist + * -1 if error + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_ccache_iterate_has_next(cc_ccache_iterate_t *iterate) +{ + if ( iterate == NULL ) + return 0; + return cci_generic_iterate_has_next((cc_generic_iterate_t*)iterate); +} + +/** + * ccs_ccache_iterate_next() + * + * Purpose: Retrieve the next element from a ccache iterator and advance + * the iterator + * + * Return: non-NULL, the next element in the iterator + * NULL, the iterator list is empty or iterator is invalid + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_ccache_iterate_next(cc_ccache_iterate_t *iterate, cc_ccache_list_node_t ** nodepp) +{ + if ( iterate == NULL || nodepp == NULL) + return ccErrBadParam; + + return cci_generic_iterate_next((cc_generic_iterate_t*)iterate, (cc_ccache_list_node_t**)nodepp); +} + +/** + * ccs_credentials_iterate_has_next() + * + * Purpose: Determine if a credentials iterator has a next element + * + * Return: 1 if another element exists + * 0 if no additional elements exist + * -1 if error + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_credentials_iterate_has_next(cc_credentials_iterate_t *iterate) +{ + if ( iterate == NULL ) + return 0; + + return cci_generic_iterate_has_next((cc_generic_iterate_t*)iterate); +} + +/** + * ccs_credentials_iterate_next() + * + * Purpose: Retrieve the next element from a credentials iterator and advance + * the iterator + * + * Return: non-NULL, the next element in the iterator + * NULL, the iterator list is empty or iterator is invalid + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_credentials_iterate_next(cc_credentials_iterate_t *iterate, cc_credentials_list_node_t** nodepp) +{ + if ( iterate == NULL || nodepp == NULL ) + return ccErrBadParam; + return cci_generic_iterate_next((cc_generic_iterate_t*)iterate, (cc_credentials_list_node_t**)nodepp); +} + +/** + * ccs_context_list_destroy() + * + * Purpose: Deallocate a list and all of its contents + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + */ +cc_int32 +ccs_context_list_destroy(cc_context_list_head_t* head) +{ + return cci_generic_list_destroy((cc_generic_list_head_t*)head); +} + +/** + * ccs_ccache_list_destroy() + * + * Purpose: Deallocate a list and all of its contents + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + */ +cc_int32 +ccs_ccache_list_destroy(cc_ccache_list_head_t* head) +{ + return cci_generic_list_destroy((cc_generic_list_head_t*)head); +} + +/** + * ccs_credentials_list_destroy() + * + * Purpose: Deallocate a list and all of its contents + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + */ +cc_int32 +ccs_credentials_list_destroy(cc_credentials_list_head_t* head) +{ + return cci_generic_list_destroy((cc_generic_list_head_t*)head); +} + +/** + * ccs_context_list_copy() + * + * Purpose: Copy a list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrBadParam, ccErrNoMem + * + */ +cc_int32 +ccs_context_list_copy(cc_context_list_head_t* head, cc_context_list_head_t** headpp ) +{ + return cci_generic_list_copy((cc_generic_list_head_t*)head, (cc_context_list_head_t **)headpp); +} + +/** + * ccs_ccache_list_copy() + * + * Purpose: Copy a list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrBadParam, ccErrNoMem + */ +cc_int32 +ccs_ccache_list_copy(cc_ccache_list_head_t* head, cc_ccache_list_head_t** headpp) +{ + return cci_generic_list_copy((cc_generic_list_head_t*)head, (cc_ccache_list_head_t **)headpp); +} + +/** + * ccs_credentials_list_copy() + * + * Purpose: Copy a list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrBadParam, ccErrNoMem + * + */ +cc_int32 +ccs_credentials_list_copy(cc_credentials_list_head_t* head, cc_credentials_list_head_t** headpp) +{ + return cci_generic_list_copy((cc_generic_list_head_t*)head, (cc_credentials_list_head_t **)headpp); +} + + +/** + * ccs_context_list_new() + * + * Purpose: Allocate a new context list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +ccs_context_list_new(cc_context_list_head_t ** headpp) +{ + cc_context_list_head_t *ret; + + if ( headpp == NULL ) + return ccErrBadParam; + + ret = (cc_context_list_head_t *)malloc(sizeof(cc_context_list_head_t)); + if (ret == NULL) + return ccErrNoMem; + ret->head = ret->tail = NULL; + ret->type = context; + *headpp = ret; + return ccNoError; +} + +/** + * ccs_context_list_append() + * + * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +ccs_context_list_append(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t** nodepp) +{ + return cci_generic_list_append((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_context_t), (cc_context_list_node_t**)nodepp); +} + +/** + * ccs_context_list_prepend() + * + * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +ccs_context_list_prepend(cc_context_list_head_t *head, cc_server_context_t *data, cc_context_list_node_t** nodepp ) +{ + return cci_generic_list_prepend((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_context_t), (cc_context_list_node_t**)nodepp); +} + +/** + * ccs_context_list_remove_element + * + * Purpose: Remove a node from the list + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + */ +cc_int32 +ccs_context_list_remove_element(cc_context_list_head_t* head, cc_context_list_node_t* rem) +{ + return cci_generic_list_remove_element((cc_generic_list_head_t*)head, (cc_generic_list_node_t*)rem); +} + +/** + * ccs_context_list_iterator() + * + * Purpose: Allocate an iterator for the specified list + * + * Return: non-NULL, an iterator + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +ccs_context_list_iterator(cc_context_list_head_t *head, cc_context_iterate_t** iterpp) +{ + cc_context_iterate_t* iterator; + + if ( head == NULL || iterpp == NULL ) + return ccErrBadParam; + + iterator = (cc_context_iterate_t*)malloc(sizeof(cc_context_iterate_t)); + if (iterator == NULL) + return ccErrNoMem; + + iterator->next = head->head; + *iterpp = iterator; + return ccNoError; +} + +/** + * ccs_context_free_iterator() + * + * Purpose: Deallocate memory associated with an iterator + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_context_free_iterator(cc_context_iterate_t* iterator) +{ + if ( iterator == NULL ) + return ccErrBadParam; + + iterator->next = NULL; + free(iterator); + return ccNoError; +} + +/** + * ccs_ccache_list_new() + * + * Purpose: Allocate a new ccache list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrNoMem + */ +cc_int32 +ccs_ccache_list_new(cc_ccache_list_head_t ** listpp) +{ + cc_ccache_list_head_t *ret; + + if ( listpp == NULL ) + return ccErrBadParam; + + ret = (cc_ccache_list_head_t *)malloc(sizeof(cc_ccache_list_head_t)); + if (ret == NULL) + return ccErrNoMem; + + ret->head = ret->tail = NULL; + *listpp = ret; + return ccNoError; +} + +/** + * ccs_ccache_list_append() + * + * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +ccs_ccache_list_append(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t** nodepp) +{ + return cci_generic_list_append((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_ccache_t), (cc_ccache_list_node_t**)nodepp); +} + +/** + * ccs_ccache_list_prepend() + * + * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +ccs_ccache_list_prepend(cc_ccache_list_head_t *head, cc_server_ccache_t *data, cc_ccache_list_node_t** nodepp) +{ + return cci_generic_list_prepend((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_ccache_t), (cc_ccache_list_node_t**)nodepp); +} + +/** + * ccs_ccache_list_remove_element() + * + * Purpose: Remove a node from the list + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_ccache_list_remove_element(cc_ccache_list_head_t* head, cc_ccache_list_node_t* rem) +{ + return cci_generic_list_remove_element((cc_generic_list_head_t*)head, (cc_generic_list_node_t*)rem); +} + +/** + * ccs_ccache_list_iterator() + * + * Purpose: Allocate an iterator for the specified list + * + * Return: non-NULL, an iterator + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +ccs_ccache_list_iterator(cc_ccache_list_head_t *head, cc_ccache_iterate_t** iterpp) +{ + cc_ccache_iterate_t* iterator; + + if ( head == NULL || iterpp == NULL ) + return ccErrBadParam; + + iterator = (cc_ccache_iterate_t*)malloc(sizeof(cc_ccache_iterate_t)); + if (iterator == NULL) + return ccErrNoMem; + + iterator->next = head->head; + *iterpp = iterator; + return ccNoError; +} + +/** + * ccs_ccache_free_iterator() + * + * Purpose: Deallocate memory associated with an iterator + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_ccache_free_iterator(cc_ccache_iterate_t* iterator) +{ + if ( iterator == NULL ) + return ccErrBadParam; + + iterator->next = NULL; + free(iterator); + return ccNoError; +} + +/** + * ccs_credentials_list_new() + * + * Purpose: Allocate a new ccache list + * + * Return: non-NULL, a new list + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +ccs_credentials_list_new(cc_credentials_list_head_t ** list) +{ + if ( list == NULL ) + return ccErrBadParam; + + *list = (cc_credentials_list_head_t *)malloc(sizeof(cc_credentials_list_head_t)); + if (*list == NULL) + return ccErrNoMem; + + (*list)->head = (*list)->tail = NULL; + return ccNoError; +} + +/** + * ccs_credentials_list_append() + * + * Purpose: Appends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +ccs_credentials_list_append(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t** nodepp ) +{ + return cci_generic_list_append((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_credentials_t), (cc_credentials_list_node_t**)nodepp); +} + +/** + * ccs_credentials_list_prepend() + * + * Purpose: Prepends a new node containing a copy of 'len' bytes of 'data' + * + * Return: non-NULL, a pointer to the newly allocated node + * NULL, failure + * + * Errors: ccErrNoMem,ccErrBadParam + * + */ +cc_int32 +ccs_credentials_list_prepend(cc_credentials_list_head_t *head, cc_server_credentials_t *data, cc_credentials_list_node_t** nodepp) +{ + return cci_generic_list_prepend((cc_generic_list_head_t *)head, (void *)data, sizeof(cc_server_credentials_t), (cc_credentials_list_node_t**)nodepp); +} + +/** + * ccs_credentials_list_remove_element() + * + * Purpose: Remove a node from the list + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_credentials_list_remove_element(cc_credentials_list_head_t* head, cc_credentials_list_node_t* rem) +{ + return cci_generic_list_remove_element((cc_generic_list_head_t*)head, (cc_generic_list_node_t*)rem); +} + +/** + * ccs_credentials_list_iterator() + * + * Purpose: Allocate an iterator for the specified list + * + * Return: non-NULL, an iterator + * NULL, failure + * + * Errors: ccErrNoMem + * + */ +cc_int32 +ccs_credentials_list_iterator(cc_credentials_list_head_t *head, cc_credentials_iterate_t** iterpp) +{ + cc_credentials_iterate_t* iterator; + + if ( head == NULL || iterpp == NULL ) + return ccErrBadParam; + + iterator = (cc_credentials_iterate_t*)malloc(sizeof(cc_credentials_iterate_t)); + if (iterator == NULL) + return ccErrNoMem; + + iterator->next = head->head; + *iterpp = iterator; + return ccNoError; +} + +/** + * ccs_credentials_free_iterator() + * + * Purpose: Deallocate memory associated with an iterator + * + * Return: 0, success + * -1, failure + * + * Errors: ccErrBadParam + * + */ +cc_int32 +ccs_credentials_free_iterator(cc_credentials_iterate_t* iterator) +{ + if ( iterator == NULL ) + return ccErrBadParam; + + iterator->next = NULL; + free(iterator); + return ccNoError; +} + diff --git a/src/lib/ccapi/server/mac/CCacheServer.plist b/src/lib/ccapi/server/mac/CCacheServer.plist new file mode 100644 index 0000000000..987cf71102 --- /dev/null +++ b/src/lib/ccapi/server/mac/CCacheServer.plist @@ -0,0 +1,12 @@ + + + + + ServiceName + edu.mit.Kerberos.CCacheServer.ipcService + Command + /System/Library/CoreServices/CCacheServer.app/Contents/MacOS/CCacheServer + OnDemand + + + diff --git a/src/lib/ccapi/server/mac/CCacheServerInfo.plist b/src/lib/ccapi/server/mac/CCacheServerInfo.plist new file mode 100644 index 0000000000..e03d5f3ffa --- /dev/null +++ b/src/lib/ccapi/server/mac/CCacheServerInfo.plist @@ -0,0 +1,38 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + CCacheServer + CFBundleGetInfoString + 4.1 + CFBundleIconFile + + CFBundleIdentifier + edu.mit.Kerberos.CCacheServer + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + Kerberos Credentials Cache Server + CFBundlePackageType + APPL + CFBundleSignature + CCSa + CFBundleVersion + 0.0.1d1 + CFBundleShortVersionString + 5.5 + CFBundleGetInfoString + 5.5 Copyright MIT + KfMDisplayVersion + 5.5 Copyright MIT + KfMDisplayCopyright + Copyright MIT + NSHumanReadableCopyright + 5.5 Copyright MIT + LSBackgroundOnly + 1 + + diff --git a/src/lib/ccapi/server/mac/main.c b/src/lib/ccapi/server/mac/main.c new file mode 100644 index 0000000000..a9da8da6c8 --- /dev/null +++ b/src/lib/ccapi/server/mac/main.c @@ -0,0 +1,33 @@ +#include +#include +#include +#include "CredentialsCache.h" +#include "msg.h" +#include "migServer.h" + +#include + +int main (int argc, const char *argv[]) +{ + cc_int32 code = 0; + int running = 1; + + openlog (argv[0], LOG_CONS | LOG_PID, LOG_AUTH); + syslog (LOG_INFO, "Starting up."); + + if (!code) { + code = ccs_serv_initialize(); + } + + if (!code) { + code = kipc_server_run_server (ccapi_server); + } + + /* cleanup ccs resources */ + ccs_serv_cleanup(); + + syslog (LOG_NOTICE, "Exiting: %s (%d)", kipc_error_string (code), code); + + /* exit */ + return code ? 1 : 0; +} diff --git a/src/lib/ccapi/server/rpc_auth.c b/src/lib/ccapi/server/rpc_auth.c index dd338e010c..66bc6aee9c 100644 --- a/src/lib/ccapi/server/rpc_auth.c +++ b/src/lib/ccapi/server/rpc_auth.c @@ -49,10 +49,13 @@ #include "rpc_auth.h" cc_int32 -cci_rpc_is_authorized( cc_auth_info_t* msg_auth, cc_session_info_t* msg_session, cc_auth_info_t* stored_auth, +ccs_rpc_is_authorized( cc_auth_info_t* msg_auth, cc_session_info_t* msg_session, cc_auth_info_t* stored_auth, cc_session_info_t* stored_session, cc_uint32 * authorizedp) { - if (msg_auth == stored_auth && msg_session == stored_session) + if (msg_auth->len == stored_auth->len && + !memcmp(msg_auth->info, stored_auth->info, msg_auth->len) && + msg_session->len == stored_session->len && + !memcmp(msg_session->info, stored_session->info, msg_session->len)) *authorizedp = 1; else *authorizedp = 0; diff --git a/src/lib/ccapi/server/serv_ops.c b/src/lib/ccapi/server/serv_ops.c index 30a108a344..52c62f45cc 100644 --- a/src/lib/ccapi/server/serv_ops.c +++ b/src/lib/ccapi/server/serv_ops.c @@ -1,6 +1,6 @@ /* $Copyright: * - * Copyright 2004 by the Massachusetts Institute of Technology. + * Copyright 2004-2006 by the Massachusetts Institute of Technology. * * All rights reserved. * @@ -50,6 +50,7 @@ #include "datastore.h" #include "rpc_auth.h" #include "msg_headers.h" +#include "marshall.h" #include #include @@ -62,33 +63,39 @@ extern int cc_myversion; extern char cc_vendor[]; cc_int32 -cci_serv_initialize(void) +ccs_serv_initialize(void) { cc_int32 code; - code = cci_context_list_new(&AllContexts); + code = ccs_context_list_new(&AllContexts); if ( code != ccNoError ) return code; TypeToOpMapping = (type_to_op_mapping_t*)malloc(sizeof(type_to_op_mapping_t)); if (TypeToOpMapping == NULL) { - cci_context_list_destroy(AllContexts); + ccs_context_list_destroy(AllContexts); return ccErrNoMem; } +#if 0 + /* These message types are only generated by the server in response + * to a request. They are never received. + */ + TypeToOpMapping->operations[ccmsg_ACK] = ccop_ACK; + TypeToOpMapping->operations[ccmsg_NACK] = ccop_NACK; +#endif TypeToOpMapping->operations[ccmsg_INIT] = ccop_INIT; TypeToOpMapping->operations[ccmsg_CTX_RELEASE] = ccop_CTX_RELEASE; TypeToOpMapping->operations[ccmsg_CTX_GET_CHANGE_TIME] = ccop_CTX_GET_CHANGE_TIME; TypeToOpMapping->operations[ccmsg_CTX_GET_DEFAULT_CCACHE_NAME] = ccop_CTX_GET_DEFAULT_CCACHE_NAME; - TypeToOpMapping->operations[ccmsg_CTX_COMPARE] = ccop_CTX_COMPARE; + TypeToOpMapping->operations[ccmsg_CTX_CCACHE_OPEN] = ccop_CTX_CCACHE_OPEN; + TypeToOpMapping->operations[ccmsg_CTX_CCACHE_OPEN_DEFAULT] = ccop_CTX_CCACHE_OPEN_DEFAULT; + TypeToOpMapping->operations[ccmsg_CTX_CCACHE_CREATE] = ccop_CTX_CCACHE_CREATE; + TypeToOpMapping->operations[ccmsg_CTX_CCACHE_CREATE_DEFAULT] = ccop_CTX_CCACHE_CREATE_DEFAULT; + TypeToOpMapping->operations[ccmsg_CTX_CCACHE_CREATE_UNIQUE] = ccop_CTX_CCACHE_CREATE_UNIQUE; TypeToOpMapping->operations[ccmsg_CTX_NEW_CCACHE_ITERATOR] = ccop_CTX_NEW_CCACHE_ITERATOR; TypeToOpMapping->operations[ccmsg_CTX_LOCK] = ccop_CTX_LOCK; TypeToOpMapping->operations[ccmsg_CTX_UNLOCK] = ccop_CTX_UNLOCK; - TypeToOpMapping->operations[ccmsg_CTX_CLONE] = ccop_CTX_CLONE; - TypeToOpMapping->operations[ccmsg_CCACHE_OPEN] = ccop_CCACHE_OPEN; - TypeToOpMapping->operations[ccmsg_CCACHE_OPEN_DEFAULT] = ccop_CCACHE_OPEN_DEFAULT; - TypeToOpMapping->operations[ccmsg_CCACHE_CREATE] = ccop_CCACHE_CREATE; - TypeToOpMapping->operations[ccmsg_CCACHE_CREATE_DEFAULT] = ccop_CCACHE_CREATE_DEFAULT; - TypeToOpMapping->operations[ccmsg_CCACHE_CREATE_UNIQUE] = ccop_CCACHE_CREATE_UNIQUE; + TypeToOpMapping->operations[ccmsg_CTX_COMPARE] = ccop_CTX_COMPARE; TypeToOpMapping->operations[ccmsg_CCACHE_RELEASE] = ccop_CCACHE_RELEASE; TypeToOpMapping->operations[ccmsg_CCACHE_DESTROY] = ccop_CCACHE_DESTROY; TypeToOpMapping->operations[ccmsg_CCACHE_SET_DEFAULT] = ccop_CCACHE_SET_DEFAULT; @@ -96,9 +103,12 @@ cci_serv_initialize(void) TypeToOpMapping->operations[ccmsg_CCACHE_GET_NAME] = ccop_CCACHE_GET_NAME; TypeToOpMapping->operations[ccmsg_CCACHE_GET_PRINCIPAL] = ccop_CCACHE_GET_PRINCIPAL; TypeToOpMapping->operations[ccmsg_CCACHE_SET_PRINCIPAL] = ccop_CCACHE_SET_PRINCIPAL; - TypeToOpMapping->operations[ccmsg_CCACHE_CREDS_ITERATOR] = ccop_CCACHE_CREDS_ITERATOR; + TypeToOpMapping->operations[ccmsg_CCACHE_NEW_CREDS_ITERATOR] = ccop_CCACHE_NEW_CREDS_ITERATOR; TypeToOpMapping->operations[ccmsg_CCACHE_STORE_CREDS] = ccop_CCACHE_STORE_CREDS; TypeToOpMapping->operations[ccmsg_CCACHE_REM_CREDS] = ccop_CCACHE_REM_CREDS; + TypeToOpMapping->operations[ccmsg_CCACHE_MOVE] = ccop_CCACHE_MOVE; + TypeToOpMapping->operations[ccmsg_CCACHE_LOCK] = ccop_CCACHE_LOCK; + TypeToOpMapping->operations[ccmsg_CCACHE_UNLOCK] = ccop_CCACHE_UNLOCK; TypeToOpMapping->operations[ccmsg_CCACHE_GET_LAST_DEFAULT_TIME] = ccop_CCACHE_GET_LAST_DEFAULT_TIME; TypeToOpMapping->operations[ccmsg_CCACHE_GET_CHANGE_TIME] = ccop_CCACHE_GET_CHANGE_TIME; TypeToOpMapping->operations[ccmsg_CCACHE_COMPARE] = ccop_CCACHE_COMPARE; @@ -107,48 +117,61 @@ cci_serv_initialize(void) TypeToOpMapping->operations[ccmsg_CCACHE_CLEAR_KDC_TIME_OFFSET] = ccop_CCACHE_CLEAR_KDC_TIME_OFFSET; TypeToOpMapping->operations[ccmsg_CCACHE_ITERATOR_RELEASE] = ccop_CCACHE_ITERATOR_RELEASE; TypeToOpMapping->operations[ccmsg_CCACHE_ITERATOR_NEXT] = ccop_CCACHE_ITERATOR_NEXT; + TypeToOpMapping->operations[ccmsg_CCACHE_ITERATOR_CLONE] = ccop_CCACHE_ITERATOR_CLONE; TypeToOpMapping->operations[ccmsg_CREDS_ITERATOR_RELEASE] = ccop_CREDS_ITERATOR_RELEASE; TypeToOpMapping->operations[ccmsg_CREDS_ITERATOR_NEXT] = ccop_CREDS_ITERATOR_NEXT; - TypeToOpMapping->operations[ccmsg_CREDS_RELEASE] = ccop_CREDS_RELEASE; + TypeToOpMapping->operations[ccmsg_CREDS_ITERATOR_CLONE] = ccop_CREDS_ITERATOR_CLONE; return ccNoError; }; cc_int32 -cci_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg) +ccs_serv_cleanup(void) +{ + return ccNoError; +} + +cc_int32 +ccs_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg) { cc_server_context_t* ctx; ccmsg_ctx_only_t* header = (ccmsg_ctx_only_t *)msg->header; + cc_uint32 type; + cc_uint32 header_len; + cc_handle handle; cc_int32 code; if (msg == NULL || msg->header == NULL || auth_info == NULL || session_info == NULL) return ccErrBadParam; if (AllContexts == NULL) { - code = cci_serv_initialize(); + code = ccs_serv_initialize(); if ( code != ccNoError ) return code; } - if (msg->type == ccmsg_INIT) { - return TypeToOpMapping->operations[msg->type] (NULL, auth_info, session_info, msg, resp_msg); + type = msg->type; + if (type == ccmsg_INIT) { + return TypeToOpMapping->operations[type] (NULL, auth_info, session_info, msg, resp_msg); } else { - if (msg->header_len < sizeof(ccmsg_ctx_only_t)) { + header_len = msg->header_len; + if (header_len < sizeof(ccmsg_ctx_only_t)) { return ccErrBadParam; } - code = cci_serv_find_ctx_by_handle(header->ctx, auth_info, session_info, &ctx); + handle = ntohll(header->ctx); + code = ccs_serv_find_ctx_by_handle(handle, auth_info, session_info, &ctx); if (code != ccNoError) { - cci_serv_make_nack(ccErrContextNotFound, auth_info, session_info, resp_msg); + ccs_serv_make_nack(ccErrContextNotFound, auth_info, session_info, resp_msg); return code; } - return TypeToOpMapping->operations[msg->type] (ctx, auth_info, session_info, msg, resp_msg); + return TypeToOpMapping->operations[type] (ctx, auth_info, session_info, msg, resp_msg); } } /*deprecated*/ cc_int32 -cci_serv_find_ctx(cc_auth_info_t* auth_info, cc_session_info_t* session_info, +ccs_serv_find_ctx(cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** ctxpp) { cc_context_iterate_t* ctx_iterator; @@ -157,35 +180,35 @@ cci_serv_find_ctx(cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_int32 code; cc_uint32 authorized; - code = cci_context_list_iterator(AllContexts, &ctx_iterator); + code = ccs_context_list_iterator(AllContexts, &ctx_iterator); if (code != ccNoError) return code; - while (cci_context_iterate_has_next(ctx_iterator)) { - code = cci_context_iterate_next(ctx_iterator, &ctx_node); + while (ccs_context_iterate_has_next(ctx_iterator)) { + code = ccs_context_iterate_next(ctx_iterator, &ctx_node); if (code != ccNoError) { - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); return code; } ctx = (cc_server_context_t *)ctx_node->data; - code = cci_rpc_is_authorized(auth_info, session_info, ctx->auth_info, ctx->session_info, &authorized); + code = ccs_rpc_is_authorized(auth_info, session_info, ctx->auth_info, ctx->session_info, &authorized); if (code != ccNoError) { - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); return code; } if (authorized) { - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); *ctxpp = ctx; return ccNoError; } } - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); return ccIteratorEnd; } cc_int32 -cci_serv_find_ctx_by_handle(cc_handle ctx_num, cc_auth_info_t* auth, cc_session_info_t* session, cc_server_context_t** ctxpp) +ccs_serv_find_ctx_by_handle(cc_handle ctx_num, cc_auth_info_t* auth, cc_session_info_t* session, cc_server_context_t** ctxpp) { cc_server_context_t* input_ctx = (cc_server_context_t*)ctx_num; cc_context_iterate_t* ctx_iterator; @@ -194,36 +217,36 @@ cci_serv_find_ctx_by_handle(cc_handle ctx_num, cc_auth_info_t* auth, cc_session_ cc_uint32 authorized; cc_int32 code; - code = cci_context_list_iterator(AllContexts, &ctx_iterator); + code = ccs_context_list_iterator(AllContexts, &ctx_iterator); if (code != ccNoError) return code; - while (cci_context_iterate_has_next(ctx_iterator)) { - code = cci_context_iterate_next(ctx_iterator, &ctx_node); + while (ccs_context_iterate_has_next(ctx_iterator)) { + code = ccs_context_iterate_next(ctx_iterator, &ctx_node); ctx = (cc_server_context_t *)ctx_node->data; if (code != ccNoError) { - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); return code; } - code = cci_rpc_is_authorized(auth, session, ctx->auth_info, ctx->session_info, &authorized); + code = ccs_rpc_is_authorized(auth, session, ctx->auth_info, ctx->session_info, &authorized); if (code != ccNoError) { - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); return code; } if (ctx == input_ctx && authorized) { - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); *ctxpp = ctx; return ccNoError; } } - cci_context_free_iterator(ctx_iterator); + ccs_context_free_iterator(ctx_iterator); return ccIteratorEnd; } cc_int32 -cci_serv_find_ccache_by_handle(cc_server_context_t* ctx, cc_handle ccache, cc_server_ccache_t** ccachepp ) +ccs_serv_find_ccache_by_handle(cc_server_context_t* ctx, cc_handle ccache, cc_server_ccache_t** ccachepp ) { cc_ccache_iterate_t* ccache_iterator; cc_ccache_list_node_t* ccache_node; @@ -231,31 +254,31 @@ cci_serv_find_ccache_by_handle(cc_server_context_t* ctx, cc_handle ccache, cc_se cc_server_ccache_t* target_ccache = (cc_server_ccache_t*)ccache; cc_int32 code; - code = cci_ccache_list_iterator(ctx->ccaches, &ccache_iterator); + code = ccs_ccache_list_iterator(ctx->ccaches, &ccache_iterator); if (code != ccNoError) return code; - while (cci_ccache_iterate_has_next(ccache_iterator)) { - code = cci_ccache_iterate_next(ccache_iterator, &ccache_node); + while (ccs_ccache_iterate_has_next(ccache_iterator)) { + code = ccs_ccache_iterate_next(ccache_iterator, &ccache_node); if (code != ccNoError) { - cci_ccache_free_iterator(ccache_iterator); + ccs_ccache_free_iterator(ccache_iterator); return code; } stored_ccache = (cc_server_ccache_t *)ccache_node->data; if (stored_ccache == target_ccache) { - cci_ccache_free_iterator(ccache_iterator); + ccs_ccache_free_iterator(ccache_iterator); *ccachepp = stored_ccache; return ccNoError; } } - cci_ccache_free_iterator(ccache_iterator); + ccs_ccache_free_iterator(ccache_iterator); return ccIteratorEnd; } cc_int32 -cci_serv_find_ccache_iterator_by_handle(cc_server_context_t* ctx, cc_handle iterator, cc_generic_list_node_t** nodepp ) +ccs_serv_find_ccache_iterator_by_handle(cc_server_context_t* ctx, cc_handle iterator, cc_generic_list_node_t** nodepp ) { cc_generic_iterate_t* gen_iterator; cc_generic_list_node_t* gen_node; @@ -286,7 +309,7 @@ cci_serv_find_ccache_iterator_by_handle(cc_server_context_t* ctx, cc_handle iter } cc_int32 -cci_serv_find_creds_iterator_by_handle(cc_server_ccache_t* ccache, cc_handle iterator, cc_generic_list_node_t** nodepp) +ccs_serv_find_creds_iterator_by_handle(cc_server_ccache_t* ccache, cc_handle iterator, cc_generic_list_node_t** nodepp) { cc_generic_iterate_t* gen_iterator; cc_generic_list_node_t* gen_node; @@ -317,7 +340,7 @@ cci_serv_find_creds_iterator_by_handle(cc_server_ccache_t* ccache, cc_handle ite } cc_int32 -cci_serv_make_nack(cc_int32 err_code, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg) +ccs_serv_make_nack(cc_int32 err_code, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg) { ccmsg_nack_t* nack_header; cc_int32 code; @@ -333,7 +356,7 @@ cci_serv_make_nack(cc_int32 err_code, cc_auth_info_t* auth_info, cc_session_info return ccErrNoMem; } - nack_header->err_code = err_code;; + nack_header->err_code = htonl(err_code); code = cci_msg_add_header(*resp_msg, nack_header, sizeof(ccmsg_nack_t)); if (code != ccNoError) { cci_msg_destroy(*resp_msg); @@ -345,7 +368,7 @@ cci_serv_make_nack(cc_int32 err_code, cc_auth_info_t* auth_info, cc_session_info } cc_int32 -cci_serv_make_ack(void * header, cc_int32 header_len, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg) +ccs_serv_make_ack(void * header, cc_int32 header_len, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg) { cc_int32 code; @@ -375,54 +398,58 @@ ccop_INIT( cc_server_context_t* ctx, /* not used */ ccmsg_init_resp_t *resp_header; ccmsg_init_t *header = (ccmsg_init_t *)msg->header; cc_context_list_node_t* ctx_node; + cc_uint32 header_len, in_version; + cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_init_t)) { + header_len = msg->header_len; + if (ctx != NULL || header_len != sizeof(ccmsg_init_t)) { return ccErrBadParam; } - code = cci_context_new(header->in_version, auth_info, session_info, &new_ctx); + in_version = ntohl(header->in_version); + code = ccs_context_new(in_version, auth_info, session_info, &new_ctx); if (code != ccNoError) { return code; } - code = cci_context_list_append(AllContexts, ctx, &ctx_node); + code = ccs_context_list_append(AllContexts, new_ctx, &ctx_node); if (code != ccNoError) { - cci_context_destroy(new_ctx); + ccs_context_destroy(new_ctx); return code; } resp_header = (ccmsg_init_resp_t*)malloc(sizeof(ccmsg_init_resp_t)); if (resp_header == NULL) { - cci_context_destroy(new_ctx); + ccs_context_destroy(new_ctx); return ccErrNoMem; } code = cci_msg_new(ccmsg_ACK, resp_msg); if (code != ccNoError) { free(resp_header); - cci_context_destroy(new_ctx); + ccs_context_destroy(new_ctx); return code; } code = cci_msg_add_data_blob(*resp_msg, cc_vendor, strlen(cc_vendor) + 1, &blob_pos); if (code != ccNoError) { free(resp_header); - cci_context_destroy(new_ctx); + ccs_context_destroy(new_ctx); cci_msg_destroy(*resp_msg); *resp_msg = 0; return code; } - resp_header->out_ctx = new_ctx; - resp_header->out_version = cc_myversion; - resp_header->vendor_offset = blob_pos; - resp_header->vendor_length = strlen(cc_vendor) + 1; + resp_header->out_ctx = htonll((cc_handle) new_ctx); + resp_header->out_version = htonl(cc_myversion); + resp_header->vendor_offset = htonl(blob_pos); + resp_header->vendor_length = htonl(strlen(cc_vendor) + 1); code = cci_msg_add_header(*resp_msg, resp_header, sizeof(ccmsg_init_resp_t)); if (code != ccNoError) { free(resp_header); - cci_context_destroy(new_ctx); + ccs_context_destroy(new_ctx); cci_msg_destroy(*resp_msg); *resp_msg = 0; return code; @@ -438,16 +465,18 @@ ccop_CTX_RELEASE( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { ccmsg_ctx_release_t* header = (ccmsg_ctx_release_t *)msg->header; + cc_uint32 header_len = msg->header_len; + cc_handle handle = ntohll(header->ctx); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ctx_release_t)) { + if (header_len != sizeof(ccmsg_ctx_release_t)) { return ccErrBadParam; } - code = cci_context_destroy(header->ctx); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + code = ccs_context_destroy((cc_server_context_t *)handle); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 @@ -458,10 +487,11 @@ ccop_CTX_GET_CHANGE_TIME( cc_server_context_t* ctx, { ccmsg_ctx_get_change_time_resp_t* resp_header; ccmsg_ctx_get_change_time_t *header = (ccmsg_ctx_get_change_time_t *)msg->header; + cc_uint32 header_len = msg->header_len; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ctx_get_change_time_t)) { + if (header_len != sizeof(ccmsg_ctx_get_change_time_t)) { return ccErrBadParam; } @@ -470,8 +500,8 @@ ccop_CTX_GET_CHANGE_TIME( cc_server_context_t* ctx, return ccErrNoMem; } - resp_header->time = ctx->changed; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ctx_get_change_time_resp_t), auth_info, session_info, resp_msg); + resp_header->time = htonll(ctx->changed); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ctx_get_change_time_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -483,15 +513,16 @@ ccop_CTX_GET_DEFAULT_CCACHE_NAME( cc_server_context_t* ctx, char * name; ccmsg_ctx_get_default_ccache_name_resp_t* resp_header; ccmsg_ctx_get_default_ccache_name_t* header = (ccmsg_ctx_get_default_ccache_name_t *)msg->header; + cc_uint32 header_len = htonl(msg->header_len); cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ctx_get_default_ccache_name_t)) { + if (header_len != sizeof(ccmsg_ctx_get_default_ccache_name_t)) { return ccErrBadParam; } - code = cci_context_get_default_ccache_name(ctx, &name); + code = ccs_context_get_default_ccache_name(ctx, &name); if (code != ccNoError) return code; @@ -507,7 +538,7 @@ ccop_CTX_GET_DEFAULT_CCACHE_NAME( cc_server_context_t* ctx, } code = cci_msg_add_data_blob(*resp_msg, name, strlen(name) + 1, &resp_header->name_offset); - resp_header->name_len = strlen(name) + 1; + resp_header->name_len = htonl(strlen(name) + 1); return ccNoError; } @@ -520,21 +551,22 @@ ccop_CTX_COMPARE(cc_server_context_t* ctx, cc_server_context_t *ctx2; ccmsg_ctx_compare_resp_t* resp_header; ccmsg_ctx_compare_t* header = (ccmsg_ctx_compare_t *)msg->header; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ctx_compare_t)) + if (header_len != sizeof(ccmsg_ctx_compare_t)) return ccErrBadParam; - code = cci_serv_find_ctx_by_handle(header->ctx2, auth_info, session_info, &ctx2); + code = ccs_serv_find_ctx_by_handle(header->ctx2, auth_info, session_info, &ctx2); resp_header = (ccmsg_ctx_compare_resp_t*)malloc(sizeof(ccmsg_ctx_compare_resp_t)); if (resp_header == NULL) return ccErrNoMem; - resp_header->is_equal = cci_context_compare(ctx, ctx2); - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ctx_compare_resp_t), auth_info, session_info, resp_msg); + resp_header->is_equal = htonl(ccs_context_compare(ctx, ctx2)); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ctx_compare_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -546,22 +578,23 @@ ccop_CTX_NEW_CCACHE_ITERATOR(cc_server_context_t* ctx, cc_ccache_iterate_t* ccache_iterator; ccmsg_ctx_new_ccache_iterator_resp_t* resp_header; ccmsg_ctx_new_ccache_iterator_t* header = (ccmsg_ctx_new_ccache_iterator_t*)msg->header; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ctx_new_ccache_iterator_t)) + if (header_len != sizeof(ccmsg_ctx_new_ccache_iterator_t)) return ccErrBadParam; - code = cci_context_ccache_iterator(ctx,&ccache_iterator); + code = ccs_context_ccache_iterator(ctx, &ccache_iterator); resp_header = (ccmsg_ctx_new_ccache_iterator_resp_t*)malloc(sizeof(ccmsg_ctx_new_ccache_iterator_resp_t)); if (resp_header == NULL) return ccErrNoMem; - resp_header->iterator = ccache_iterator; + resp_header->iterator = htonll((cc_handle) ccache_iterator); - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ctx_new_ccache_iterator_resp_t), auth_info, session_info, resp_msg); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ctx_new_ccache_iterator_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -571,7 +604,7 @@ ccop_CTX_LOCK( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { // TODO - return cci_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); } cc_int32 @@ -581,7 +614,7 @@ ccop_CTX_UNLOCK( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { // TODO - return cci_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); } cc_int32 @@ -591,11 +624,11 @@ ccop_CTX_CLONE( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { // TODO - return cci_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); } cc_int32 -ccop_CCACHE_OPEN(cc_server_context_t* ctx, +ccop_CTX_CCACHE_OPEN(cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg) @@ -604,32 +637,33 @@ ccop_CCACHE_OPEN(cc_server_context_t* ctx, cc_server_ccache_t* ccache; ccmsg_ccache_open_resp_t* resp_header; ccmsg_ccache_open_t* header = (ccmsg_ccache_open_t*)msg->header; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_open_t)) + if (header_len != sizeof(ccmsg_ccache_open_t)) return ccErrBadParam; - code = cci_msg_retrieve_blob(msg, header->name_offset, header->name_len, &name); - code = cci_context_find_ccache(ctx, name, &ccache); + code = cci_msg_retrieve_blob(msg, ntohl(header->name_offset), ntohl(header->name_len), &name); + code = ccs_context_find_ccache(ctx, name, &ccache); free(name); if (ccache == NULL) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); resp_header = (ccmsg_ccache_open_resp_t*)malloc(sizeof(ccmsg_ccache_open_resp_t)); if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = ccache; - cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_open_resp_t), auth_info, session_info, resp_msg); + resp_header->ccache = htonll((cc_handle) ccache); + ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_open_resp_t), auth_info, session_info, resp_msg); return ccNoError; } cc_int32 -ccop_CCACHE_OPEN_DEFAULT(cc_server_context_t* ctx, +ccop_CTX_CCACHE_OPEN_DEFAULT(cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg) @@ -637,14 +671,15 @@ ccop_CCACHE_OPEN_DEFAULT(cc_server_context_t* ctx, ccmsg_ccache_open_default_t* header = (ccmsg_ccache_open_default_t*)msg->header; ccmsg_ccache_open_resp_t* resp_header; cc_server_ccache_t* ccache; + cc_uint32 header_len = msg->header_len; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_open_default_t)) + if (header_len != sizeof(ccmsg_ccache_open_default_t)) return ccErrBadParam; if (ctx->ccaches->head->data == NULL) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); ccache = (cc_server_ccache_t*) ctx->ccaches->head->data; @@ -652,12 +687,12 @@ ccop_CCACHE_OPEN_DEFAULT(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = ccache; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_open_resp_t), auth_info, session_info, resp_msg); + resp_header->ccache = htonll((cc_handle) ccache); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_open_resp_t), auth_info, session_info, resp_msg); } cc_int32 -ccop_CCACHE_CREATE(cc_server_context_t* ctx, +ccop_CTX_CCACHE_CREATE(cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg) @@ -667,24 +702,25 @@ ccop_CCACHE_CREATE(cc_server_context_t* ctx, cc_server_ccache_t* ccache; char* principal; char* name; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_create_t)) + if (header_len != sizeof(ccmsg_ccache_create_t)) return ccErrBadParam; - code = cci_msg_retrieve_blob(msg, header->principal_offset, header->principal_len, &principal); + code = cci_msg_retrieve_blob(msg, ntohl(header->principal_offset), ntohl(header->principal_len), &principal); if (code != ccNoError) return code; - principal[header->principal_len] = '\0'; /*Ensure null termination*/ + principal[ntohl(header->principal_len)] = '\0'; /*Ensure null termination*/ - code = cci_msg_retrieve_blob(msg, header->name_offset, header->name_len, &name); + code = cci_msg_retrieve_blob(msg, ntohl(header->name_offset), ntohl(header->name_len), &name); if (code != ccNoError) return code; - name[header->name_len] = '\0'; /*Ensure null termination*/ + name[ntohl(header->name_len)] = '\0'; /*Ensure null termination*/ - code = cci_context_create_ccache(ctx, name, header->version, principal, &ccache); + code = ccs_context_create_ccache(ctx, name, ntohl(header->version), principal, &ccache); if (code != ccNoError) return code; @@ -692,12 +728,12 @@ ccop_CCACHE_CREATE(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = ccache; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); + resp_header->ccache = htonll((cc_handle) ccache); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); } cc_int32 -ccop_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, +ccop_CTX_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg) @@ -707,23 +743,24 @@ ccop_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, cc_server_ccache_t* ccache; char* principal; char* name; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_create_t)) + if (header_len != sizeof(ccmsg_ccache_create_t)) return ccErrBadParam; - code = cci_msg_retrieve_blob(msg, header->principal_offset, header->principal_len, &principal); + code = cci_msg_retrieve_blob(msg, ntohl(header->principal_offset), ntohl(header->principal_len), &principal); if (code != ccNoError) return code; - principal[header->principal_len] = '\0'; /*Ensure null termination*/ + principal[ntohl(header->principal_len)] = '\0'; /*Ensure null termination*/ - code = cci_context_get_default_ccache_name(ctx, &name); + code = ccs_context_get_default_ccache_name(ctx, &name); if (code != ccNoError) return code; - code = cci_context_create_ccache(ctx, name, header->version, principal, &ccache); + code = ccs_context_create_ccache(ctx, name, ntohl(header->version), principal, &ccache); if (code != ccNoError) return code; @@ -731,12 +768,12 @@ ccop_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = ccache; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); + resp_header->ccache = htonll((cc_handle) ccache); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); } cc_int32 -ccop_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, +ccop_CTX_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t *msg, cc_msg_t **resp_msg) @@ -746,21 +783,23 @@ ccop_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, cc_server_ccache_t* ccache; char* principal; char* name; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_create_t)) + if (header_len != sizeof(ccmsg_ccache_create_t)) return ccErrBadParam; - code = cci_msg_retrieve_blob(msg, header->principal_offset, header->principal_len, &principal); + code = cci_msg_retrieve_blob(msg, ntohl(header->principal_offset), htonl(header->principal_len), &principal); if (code != ccNoError) return code; - principal[header->principal_len] = '\0'; /*Ensure null termination*/ + principal[ntohl(header->principal_len)] = '\0'; /*Ensure null termination*/ - // TODO: Generate a unique ccache name + // TODO: Generate a unique ccache name + name = "unique"; - code = cci_context_create_ccache(ctx, name, header->version, principal, &ccache); + code = ccs_context_create_ccache(ctx, name, ntohl(header->version), principal, &ccache); if (code != ccNoError) return code; @@ -768,8 +807,8 @@ ccop_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->ccache = ccache; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); + resp_header->ccache = htonll((cc_handle) ccache); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_create_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -790,20 +829,21 @@ ccop_CCACHE_DESTROY( cc_server_context_t* ctx, { ccmsg_ccache_release_t* header = (ccmsg_ccache_release_t*)msg->header; cc_server_ccache_t* ccache; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_release_t)) + if (header_len != sizeof(ccmsg_ccache_release_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - cci_ccache_destroy(ccache); + ccs_ccache_destroy(ccache); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 @@ -816,39 +856,40 @@ ccop_CCACHE_SET_DEFAULT(cc_server_context_t* ctx, ccmsg_ccache_set_default_t* header = (ccmsg_ccache_set_default_t*)msg->header; cc_ccache_iterate_t* ccache_iterator; cc_ccache_list_node_t* ccache_node; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_set_default_t)) + if (header_len != sizeof(ccmsg_ccache_set_default_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); if (ccache == (cc_server_ccache_t*)ctx->ccaches->head->data) /*already default*/ - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); old_default = (cc_server_ccache_t*)ctx->ccaches->head->data; old_default->last_default = time(NULL); - code = cci_ccache_list_iterator(ctx->ccaches, &ccache_iterator); + code = ccs_ccache_list_iterator(ctx->ccaches, &ccache_iterator); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - while (cci_ccache_iterate_has_next(ccache_iterator)) { - code = cci_ccache_iterate_next(ccache_iterator,&ccache_node); + while (ccs_ccache_iterate_has_next(ccache_iterator)) { + code = ccs_ccache_iterate_next(ccache_iterator,&ccache_node); stored_ccache = (cc_server_ccache_t*)ccache_node->data; if (stored_ccache == ccache) { ccache_node->data = NULL; /*don't want list removal code free()ing ccache*/ - cci_ccache_list_remove_element(ctx->ccaches, ccache_node); - cci_ccache_list_prepend(ctx->ccaches, ccache, NULL); + ccs_ccache_list_remove_element(ctx->ccaches, ccache_node); + ccs_ccache_list_prepend(ctx->ccaches, ccache, NULL); break; } } - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 @@ -860,23 +901,24 @@ ccop_CCACHE_GET_CREDS_VERSION(cc_server_context_t* ctx, ccmsg_ccache_get_creds_version_t* header = (ccmsg_ccache_get_creds_version_t*)msg->header; ccmsg_ccache_get_creds_version_resp_t* resp_header; cc_server_ccache_t* ccache; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_get_creds_version_t)) + if (header_len != sizeof(ccmsg_ccache_get_creds_version_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); resp_header = (ccmsg_ccache_get_creds_version_resp_t*)malloc(sizeof(ccmsg_ccache_get_creds_version_resp_t)); if (resp_header == NULL) return ccErrNoMem; - resp_header->version = ccache->versions; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_creds_version_resp_t), auth_info, session_info, resp_msg); + resp_header->version = htonl(ccache->versions); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_creds_version_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -888,16 +930,18 @@ ccop_CCACHE_GET_NAME(cc_server_context_t* ctx, ccmsg_ccache_get_name_t* header = (ccmsg_ccache_get_name_t*)msg->header; ccmsg_ccache_get_name_resp_t* resp_header; cc_server_ccache_t* ccache; + cc_uint32 header_len = msg->header_len; + cc_uint32 name_offset; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_get_name_resp_t)) + if (header_len != sizeof(ccmsg_ccache_get_name_resp_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (ccache == NULL) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); resp_header = (ccmsg_ccache_get_name_resp_t*)malloc(sizeof(ccmsg_ccache_get_name_resp_t)); if (resp_header == NULL) @@ -907,8 +951,11 @@ ccop_CCACHE_GET_NAME(cc_server_context_t* ctx, if (code != ccNoError) return code; - code = cci_msg_add_data_blob(*resp_msg, ccache->name, strlen(ccache->name) + 1, &resp_header->name_offset); - resp_header->name_len = strlen(ccache->name) + 1; + code = cci_msg_add_data_blob(*resp_msg, ccache->name, strlen(ccache->name) + 1, &name_offset); + if (code == 0) { + resp_header->name_len = htonl(strlen(ccache->name) + 1); + resp_header->name_offset = htonl(name_offset); + } cci_msg_add_header(*resp_msg, resp_header, sizeof(ccmsg_ccache_get_name_resp_t)); return ccNoError; @@ -924,20 +971,22 @@ ccop_CCACHE_GET_PRINCIPAL(cc_server_context_t* ctx, ccmsg_ccache_get_principal_resp_t* resp_header; cc_server_ccache_t* ccache; char * principal; + cc_uint32 header_len = msg->header_len; + cc_uint32 principal_offset; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_get_principal_t)) + if (header_len != sizeof(ccmsg_ccache_get_principal_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = cci_ccache_get_principal(ccache, header->version, &principal); + code = ccs_ccache_get_principal(ccache, ntohl(header->version), &principal); if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); code = cci_msg_new(ccmsg_ACK, resp_msg); if (code != ccNoError) @@ -947,7 +996,11 @@ ccop_CCACHE_GET_PRINCIPAL(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - code = cci_msg_add_data_blob(*resp_msg, principal, strlen(principal) + 1, &resp_header->principal_offset); + code = cci_msg_add_data_blob(*resp_msg, principal, strlen(principal) + 1, &principal_offset); + if (code == 0) { + resp_header->principal_len = htonl(strlen(principal) + 1); + resp_header->principal_offset = htonl(principal_offset); + } cci_msg_add_header(*resp_msg, resp_header, sizeof(ccmsg_ccache_get_principal_resp_t)); return ccNoError; @@ -962,50 +1015,52 @@ ccop_CCACHE_SET_PRINCIPAL(cc_server_context_t* ctx, ccmsg_ccache_set_principal_t* header = (ccmsg_ccache_set_principal_t*)msg->header; cc_server_ccache_t* ccache; char *principal; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_set_principal_t)) + if (header_len != sizeof(ccmsg_ccache_set_principal_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = cci_msg_retrieve_blob(msg, header->principal_offset, header->principal_len, &principal); + code = cci_msg_retrieve_blob(msg, ntohl(header->principal_offset), ntohl(header->principal_len), &principal); if (code != ccNoError) - return cci_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); - code = cci_ccache_set_principal(ccache, header->version, principal); + code = ccs_ccache_set_principal(ccache, ntohl(header->version), principal); if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 -ccop_CCACHE_CREDS_ITERATOR(cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, cc_msg_t **resp_msg) +ccop_CCACHE_NEW_CREDS_ITERATOR( cc_server_context_t* ctx, + cc_auth_info_t* auth_info, + cc_session_info_t* session_info, + cc_msg_t *msg, cc_msg_t **resp_msg) { cc_server_ccache_t* ccache; cc_credentials_iterate_t* creds_iterator; ccmsg_ccache_creds_iterator_t* header = (ccmsg_ccache_creds_iterator_t*)msg->header; ccmsg_ccache_creds_iterator_resp_t* resp_header; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_creds_iterator_t)) + if (header_len != sizeof(ccmsg_ccache_creds_iterator_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = cci_ccache_new_iterator(ccache, &creds_iterator); + code = ccs_ccache_new_iterator(ccache, &creds_iterator); if (code != ccNoError) return code; @@ -1013,13 +1068,13 @@ ccop_CCACHE_CREDS_ITERATOR(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - resp_header->iterator = creds_iterator; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_creds_iterator_resp_t), auth_info, session_info, resp_msg); + resp_header->iterator = htonll((cc_handle) creds_iterator); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_creds_iterator_resp_t), auth_info, session_info, resp_msg); } static cc_int32 -cci_credentials_union_release( cc_credentials_union * creds ) +ccs_credentials_union_release( cc_credentials_union * creds ) { int i; @@ -1069,24 +1124,21 @@ ccop_CCACHE_STORE_CREDS(cc_server_context_t* ctx, cc_server_ccache_t* ccache; char *flat_creds; cc_credentials_union *creds; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_store_creds_t)) + if (header_len != sizeof(ccmsg_ccache_store_creds_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - // TODO: This code is too simplistic. cc_credential_unions are not flat - // structures and must be flattened. That means that although we can - // store a flat blob in the message we will need to decode the blob - // into the actual object. - code = cci_msg_retrieve_blob(msg, header->creds_offset, header->creds_len, &flat_creds); + code = cci_msg_retrieve_blob(msg, ntohl(header->creds_offset), ntohl(header->creds_len), &flat_creds); if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); creds = (cc_credentials_union *)malloc(sizeof(cc_credentials_union)); if ( creds == NULL ) @@ -1094,24 +1146,24 @@ ccop_CCACHE_STORE_CREDS(cc_server_context_t* ctx, switch ( creds->version ) { case cc_credentials_v4: - code = cci_creds_v4_unmarshall(flat_creds, header->creds_len, creds); + code = cci_creds_v4_unmarshall(flat_creds, ntohl(header->creds_len), creds); break; case cc_credentials_v5: - code = cci_creds_v5_unmarshall(flat_creds, header->creds_len, creds); + code = cci_creds_v5_unmarshall(flat_creds, ntohl(header->creds_len), creds); break; default: - return cci_serv_make_nack(ccErrBadCredentialsVersion, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrBadCredentialsVersion, auth_info, session_info, resp_msg); } if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); - code = cci_ccache_store_creds(ccache, creds); - cci_credentials_union_release(creds); + code = ccs_ccache_store_creds(ccache, creds); + ccs_credentials_union_release(creds); if (code != ccNoError) { - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); } - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 @@ -1123,21 +1175,22 @@ ccop_CCACHE_REM_CREDS(cc_server_context_t* ctx, ccmsg_ccache_rem_creds_t* header = (ccmsg_ccache_rem_creds_t*)msg->header; cc_server_ccache_t* ccache; cc_credentials_union *creds; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_rem_creds_t)) + if (header_len != sizeof(ccmsg_ccache_rem_creds_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = cci_ccache_rem_creds(ccache, header->creds); + code = ccs_ccache_rem_creds(ccache, (const cc_credentials_union *)(ntohll(header->creds))); if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 @@ -1147,7 +1200,7 @@ ccop_CCACHE_LOCK( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { // TODO - return cci_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); } cc_int32 @@ -1157,7 +1210,7 @@ ccop_CCACHE_UNLOCK( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { // TODO - return cci_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); } cc_int32 @@ -1167,7 +1220,7 @@ ccop_CCACHE_MOVE( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { // TODO - return cci_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); } @@ -1180,23 +1233,24 @@ ccop_CCACHE_GET_LAST_DEFAULT_TIME(cc_server_context_t* ctx, ccmsg_ccache_get_last_default_time_t* header = (ccmsg_ccache_get_last_default_time_t*)msg->header; ccmsg_ccache_get_last_default_time_resp_t* resp_header; cc_server_ccache_t* ccache; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_get_last_default_time_t)) + if (header_len != sizeof(ccmsg_ccache_get_last_default_time_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); resp_header = (ccmsg_ccache_get_last_default_time_resp_t*)malloc(sizeof(ccmsg_ccache_get_last_default_time_resp_t)); if (resp_header == NULL) return ccErrNoMem; - resp_header->last_default_time = ccache->last_default; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_last_default_time_resp_t), auth_info, session_info, resp_msg); + resp_header->last_default_time = htonll(ccache->last_default); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_last_default_time_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -1208,10 +1262,11 @@ ccop_CCACHE_GET_CHANGE_TIME( cc_server_context_t* ctx, ccmsg_ccache_get_change_time_resp_t* resp_header; ccmsg_ccache_get_change_time_t *header = (ccmsg_ccache_get_change_time_t *)msg->header; cc_server_ccache_t* ccache = (cc_server_ccache_t *)header->ccache; + cc_uint32 header_len = msg->header_len; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_get_change_time_t)) { + if (header_len != sizeof(ccmsg_ccache_get_change_time_t)) { return ccErrBadParam; } @@ -1220,8 +1275,8 @@ ccop_CCACHE_GET_CHANGE_TIME( cc_server_context_t* ctx, return ccErrNoMem; } - resp_header->time = ccache->changed; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_change_time_resp_t), auth_info, session_info, resp_msg); + resp_header->time = htonll(ccache->changed); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_change_time_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -1233,27 +1288,30 @@ ccop_CCACHE_COMPARE(cc_server_context_t* ctx, ccmsg_ccache_compare_t* header = (ccmsg_ccache_compare_t*)msg->header; ccmsg_ccache_compare_resp_t* resp_header; cc_server_ccache_t* ccache1, *ccache2; + cc_uint32 header_len = msg->header_len; + cc_uint32 is_equal; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_compare_t)) + if (header_len != sizeof(ccmsg_ccache_compare_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache1, &ccache1); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache1), &ccache1); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = cci_serv_find_ccache_by_handle(ctx, header->ccache2, &ccache2); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache2), &ccache2); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); resp_header = (ccmsg_ccache_compare_resp_t*)malloc(sizeof(ccmsg_ccache_compare_resp_t)); if (resp_header == NULL) return ccErrNoMem; - cci_ccache_compare(ccache1, ccache2, &resp_header->is_equal); - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_compare_resp_t), auth_info, session_info, resp_msg); + ccs_ccache_compare(ccache1, ccache2, &is_equal); + resp_header->is_equal = htonl(is_equal); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_compare_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -1265,30 +1323,31 @@ ccop_CCACHE_GET_KDC_TIME_OFFSET(cc_server_context_t* ctx, ccmsg_ccache_get_kdc_time_offset_t* header = (ccmsg_ccache_get_kdc_time_offset_t*)msg->header; ccmsg_ccache_get_kdc_time_offset_resp_t* resp_header; cc_server_ccache_t* ccache; - cc_time_t offset; + cc_time64 offset; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_get_kdc_time_offset_t)) + if (header_len != sizeof(ccmsg_ccache_get_kdc_time_offset_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); // TODO How is the header->creds_version supposed to be used? - code = cci_ccache_get_kdc_time_offset(ccache, &offset); + code = ccs_ccache_get_kdc_time_offset(ccache, &offset); if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); resp_header = (ccmsg_ccache_get_kdc_time_offset_resp_t*)malloc(sizeof(ccmsg_ccache_get_kdc_time_offset_resp_t)); if (resp_header == NULL) return ccErrNoMem; - resp_header->offset = offset; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_kdc_time_offset_resp_t), auth_info, session_info, resp_msg); + resp_header->offset = htonll(offset); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_get_kdc_time_offset_resp_t), auth_info, session_info, resp_msg); } cc_int32 @@ -1299,21 +1358,22 @@ ccop_CCACHE_SET_KDC_TIME_OFFSET(cc_server_context_t* ctx, { ccmsg_ccache_set_kdc_time_offset_t* header = (ccmsg_ccache_set_kdc_time_offset_t*)msg->header; cc_server_ccache_t* ccache; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_set_kdc_time_offset_t)) + if (header_len != sizeof(ccmsg_ccache_set_kdc_time_offset_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); // TODO How is the header->creds_version supposed to be used? - cci_ccache_set_kdc_time_offset(ccache, header->offset); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + ccs_ccache_set_kdc_time_offset(ccache, htonll(header->offset)); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 @@ -1324,21 +1384,22 @@ ccop_CCACHE_CLEAR_KDC_TIME_OFFSET(cc_server_context_t* ctx, { ccmsg_ccache_clear_kdc_time_offset_t* header = (ccmsg_ccache_clear_kdc_time_offset_t*)msg->header; cc_server_ccache_t* ccache; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_clear_kdc_time_offset_t)) + if (header_len != sizeof(ccmsg_ccache_clear_kdc_time_offset_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); // TODO How is the header->creds_version supposed to be used? - cci_ccache_clear_kdc_time_offset(ccache); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + ccs_ccache_clear_kdc_time_offset(ccache); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } cc_int32 @@ -1349,24 +1410,35 @@ ccop_CCACHE_ITERATOR_RELEASE(cc_server_context_t* ctx, { cc_generic_list_node_t* gen_node; ccmsg_ccache_iterator_release_t* header = (ccmsg_ccache_iterator_release_t*)msg->header; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_iterator_release_t)) + if (header_len != sizeof(ccmsg_ccache_iterator_release_t)) return ccErrBadParam; - code = cci_serv_find_ccache_iterator_by_handle(ctx, header->iterator, &gen_node); + code = ccs_serv_find_ccache_iterator_by_handle(ctx, ntohll(header->iterator), &gen_node); if (code != ccNoError) - return cci_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); code = cci_generic_list_remove_element(ctx->active_iterators, gen_node); if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } +cc_int32 +ccop_CCACHE_ITERATOR_CLONE( cc_server_context_t* ctx, + cc_auth_info_t* auth_info, + cc_session_info_t* session_info, + cc_msg_t *msg, cc_msg_t **resp_msg) +{ + // TODO + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); +} + cc_int32 ccop_CCACHE_ITERATOR_NEXT(cc_server_context_t* ctx, cc_auth_info_t* auth_info, @@ -1377,32 +1449,33 @@ ccop_CCACHE_ITERATOR_NEXT(cc_server_context_t* ctx, ccmsg_ccache_iterator_next_resp_t* resp_header; cc_generic_list_node_t* gen_node; cc_ccache_iterate_t* ccache_iterator; - cc_ccache_list_node_t *ccache_node; + cc_ccache_list_node_t *ccache_node; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_ccache_iterator_next_t)) + if (header_len != sizeof(ccmsg_ccache_iterator_next_t)) return ccErrBadParam; - code = cci_serv_find_ccache_iterator_by_handle(ctx, header->iterator, &gen_node); + code = ccs_serv_find_ccache_iterator_by_handle(ctx, ntohll(header->iterator), &gen_node); if (code != ccNoError) - return cci_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); ccache_iterator = (cc_ccache_iterate_t*)gen_node->data; - if (cci_ccache_iterate_has_next(ccache_iterator)) { + if (ccs_ccache_iterate_has_next(ccache_iterator)) { resp_header = (ccmsg_ccache_iterator_next_resp_t*)malloc(sizeof(ccmsg_ccache_iterator_next_resp_t)); if (resp_header == NULL) return ccErrNoMem; - code = cci_ccache_iterate_next(ccache_iterator, &ccache_node); + code = ccs_ccache_iterate_next(ccache_iterator, &ccache_node); if (code != ccNoError) - return cci_serv_make_nack(code, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(code, auth_info, session_info, resp_msg); - resp_header->ccache = ccache_node; - return cci_serv_make_ack(resp_header, sizeof(ccmsg_ccache_iterator_next_resp_t), auth_info, session_info, resp_msg); + resp_header->ccache = htonll((cc_handle) ccache_node); + return ccs_serv_make_ack(resp_header, sizeof(ccmsg_ccache_iterator_next_resp_t), auth_info, session_info, resp_msg); } else { - return cci_serv_make_nack(ccIteratorEnd, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccIteratorEnd, auth_info, session_info, resp_msg); } } @@ -1415,28 +1488,40 @@ ccop_CREDS_ITERATOR_RELEASE(cc_server_context_t* ctx, cc_generic_list_node_t* gen_node; cc_server_ccache_t* ccache; ccmsg_creds_iterator_release_t* header = (ccmsg_creds_iterator_release_t*)msg->header; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_creds_iterator_release_t)) + if (header_len != sizeof(ccmsg_creds_iterator_release_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = cci_serv_find_creds_iterator_by_handle(ccache, header->iterator, &gen_node); + code = ccs_serv_find_creds_iterator_by_handle(ccache, ntohll(header->iterator), &gen_node); if (code != ccNoError) - return cci_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); code = cci_generic_list_remove_element(ccache->active_iterators, gen_node); if (code != ccNoError) - return cci_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); - return cci_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); + return ccs_serv_make_ack(NULL, 0, auth_info, session_info, resp_msg); } +cc_int32 +ccop_CREDS_ITERATOR_CLONE( cc_server_context_t* ctx, + cc_auth_info_t* auth_info, + cc_session_info_t* session_info, + cc_msg_t *msg, cc_msg_t **resp_msg) +{ + // TODO + return ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); +} + + cc_int32 ccop_CREDS_ITERATOR_NEXT(cc_server_context_t* ctx, cc_auth_info_t* auth_info, @@ -1451,23 +1536,24 @@ ccop_CREDS_ITERATOR_NEXT(cc_server_context_t* ctx, cc_server_ccache_t* ccache; cc_server_credentials_t* stored_creds; cc_credentials_union *creds_union; + cc_uint32 header_len = msg->header_len; cc_int32 code; *resp_msg = 0; - if (msg->header_len != sizeof(ccmsg_creds_iterator_next_t)) + if (header_len != sizeof(ccmsg_creds_iterator_next_t)) return ccErrBadParam; - code = cci_serv_find_ccache_by_handle(ctx, header->ccache, &ccache); + code = ccs_serv_find_ccache_by_handle(ctx, ntohll(header->ccache), &ccache); if (code != ccNoError) - return cci_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrCCacheNotFound, auth_info, session_info, resp_msg); - code = cci_serv_find_creds_iterator_by_handle(ccache, header->iterator, &gen_node); + code = ccs_serv_find_creds_iterator_by_handle(ccache, ntohll(header->iterator), &gen_node); if (code != ccNoError) - return cci_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); + return ccs_serv_make_nack(ccErrBadParam, auth_info, session_info, resp_msg); creds_iterator = (cc_credentials_iterate_t*)gen_node->data; - if (cci_credentials_iterate_has_next(creds_iterator)) { + if (ccs_credentials_iterate_has_next(creds_iterator)) { code = cci_msg_new(ccmsg_ACK, resp_msg); if (code != ccNoError) return code; @@ -1476,14 +1562,14 @@ ccop_CREDS_ITERATOR_NEXT(cc_server_context_t* ctx, if (resp_header == NULL) return ccErrNoMem; - code = cci_credentials_iterate_next(creds_iterator, &creds_node); + code = ccs_credentials_iterate_next(creds_iterator, &creds_node); stored_creds = (cc_server_credentials_t*)creds_node->data; creds_union = &stored_creds->creds; code = cci_msg_add_data_blob(*resp_msg, creds_union, sizeof(cc_credentials_union), &resp_header->creds_offset); code = cci_msg_add_header(*resp_msg, resp_header, sizeof(ccmsg_creds_iterator_next_resp_t)); } else { - cci_serv_make_nack(ccIteratorEnd, auth_info, session_info, resp_msg); + ccs_serv_make_nack(ccIteratorEnd, auth_info, session_info, resp_msg); } return ccNoError; } @@ -1495,6 +1581,6 @@ ccop_CREDS_RELEASE( cc_server_context_t* ctx, cc_msg_t *msg, cc_msg_t **resp_msg) { - cci_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); + ccs_serv_make_nack(ccErrNotImplemented, auth_info, session_info, resp_msg); return ccNoError; } diff --git a/src/lib/ccapi/server/serv_ops.h b/src/lib/ccapi/server/serv_ops.h deleted file mode 100644 index f439566855..0000000000 --- a/src/lib/ccapi/server/serv_ops.h +++ /dev/null @@ -1,321 +0,0 @@ -/* $Copyright: - * - * Copyright 2004 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 MIT 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. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF - * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Individual source code files are copyright MIT, Cygnus Support, - * OpenVision, Oracle, Sun Soft, FundsXpress, and others. - * - * Project Athena, Athena, Athena MUSE, Discuss, Hesiod, Kerberos, Moira, - * and Zephyr are trademarks of the Massachusetts Institute of Technology - * (MIT). No commercial use of these trademarks may be made without prior - * written permission of MIT. - * - * "Commercial use" means use of a name in a product or other for-profit - * manner. It does NOT prevent a commercial firm from referring to the MIT - * trademarks in order to convey information (although in doing so, - * recognition of their trademark status should be given). - * $ - */ - -/* - * Prototypes for serv_ops.c - */ - -#ifndef __SERV_OPS_H__ -#define __SERV_OPS_H__ - -#include "CredentialsCache.h" -#include "rpc_auth.h" -#include "msg.h" -#include "datastore.h" - -struct type_to_op_mapping_t { - cc_int32 (*operations[CC_MSG_MAX_TYPE]) ( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); -}; -typedef struct type_to_op_mapping_t type_to_op_mapping_t; - -cc_int32 cci_serv_initialize(void); -cc_int32 cci_serv_process_msg(cc_msg_t * msg, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** resp_msg); -cc_int32 cci_serv_find_ctx(cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_server_context_t** contextp); -cc_int32 cci_serv_find_ctx_by_handle(cc_handle ctx_handle, cc_auth_info_t *auth, cc_session_info_t* session, cc_server_context_t** contextp); -cc_int32 cci_serv_find_ccache_by_handle(cc_server_context_t* ctx, cc_handle ccache_handle, cc_server_ccache_t** ccachep) ; -cc_int32 cci_serv_find_ccache_iterator_by_handle(cc_server_context_t* ctx, cc_handle iterator, cc_generic_list_node_t** nodep); -cc_int32 cci_serv_find_creds_iterator_by_handle(cc_server_ccache_t* ccache, cc_handle iterator, cc_generic_list_node_t** nodep); -cc_int32 cci_serv_make_nack(cc_int32 err_code, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** msgp); -cc_int32 cci_serv_make_ack(void * header, cc_int32 header_len, cc_auth_info_t* auth_info, cc_session_info_t* session_info, cc_msg_t** msgp); - -cc_int32 ccop_INIT( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CTX_RELEASE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CTX_GET_CHANGE_TIME( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CTX_GET_DEFAULT_CCACHE_NAME( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CTX_COMPARE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CTX_NEW_CCACHE_ITERATOR( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_LOCK( cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_UNLOCK( cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CTX_CLONE( cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_OPEN( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_OPEN_DEFAULT( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_CREATE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_CREATE_DEFAULT( cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_CREATE_UNIQUE( cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_RELEASE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_DESTROY( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_SET_DEFAULT( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_GET_CREDS_VERSION( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_GET_NAME( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_GET_PRINCIPAL( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_SET_PRINCIPAL( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_CREDS_ITERATOR( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_STORE_CREDS( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_REM_CREDS( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_GET_LAST_DEFAULT_TIME( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 -ccop_CCACHE_GET_CHANGE_TIME( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg) ; - -cc_int32 ccop_CCACHE_COMPARE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_GET_KDC_TIME_OFFSET( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_SET_KDC_TIME_OFFSET( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_CLEAR_KDC_TIME_OFFSET( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_ITERATOR_RELEASE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CCACHE_ITERATOR_NEXT( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CREDS_ITERATOR_RELEASE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CREDS_ITERATOR_NEXT( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); - -cc_int32 ccop_CREDS_RELEASE( - cc_server_context_t* ctx, - cc_auth_info_t* auth_info, - cc_session_info_t* session_info, - cc_msg_t *msg, - cc_msg_t **resp_msg); -#endif /*__SERV_OPS_H__*/ diff --git a/src/lib/ccapi/unit-test/NTMakefile b/src/lib/ccapi/unit-test/NTMakefile new file mode 100644 index 0000000000..73f53f2e4e --- /dev/null +++ b/src/lib/ccapi/unit-test/NTMakefile @@ -0,0 +1,53 @@ +!include + +CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsmt) + +WINLIBS = ws2_32.lib rpcrt4.lib $(guilibsdll) + +T_CCACHE = t_ccache.exe + +T_CONTEXT = t_context.exe + +T_LISTS = t_lists.exe + +T_MSG = t_msg.exe + +T_SERVER = t_server.exe + +T_CCAPI = t_ccapi.exe + +all: $(T_CCAPI) $(T_CCACHE) $(T_CONTEXT) $(T_LISTS) $(T_MSG) $(T_SERVER) + +ntccrpc_c.c ntccrpc_s.c ntccrpc.h: ntccrpc.idl ntccrpc.acf + midl ntccrpc.idl /acf ntccrpc.acf + +CC_CLIENT_LIB = ..\client\cc_client.lib + +CC_COMMON_LIB = ..\common\cc_common.lib + +CC_SERVER_LIB = ..\server\cc_server.lib + +CC_API_LIB = ..\windows\krbcc32.lib + +$(T_CCACHE): t_ccache.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB) + $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) + +$(T_CONTEXT): t_context.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB) + $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) + +$(T_LISTS): t_lists.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB) + $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) + +$(T_MSG): t_msg.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB) + $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) + +$(T_SERVER): t_server.obj $(CC_SERVER_LIB) $(CC_COMMON_LIB) + $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) + +$(T_CCAPI): t_ccapi.obj $(CC_API_LIB) + $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) + +clean: + del *.exe *.dll *.lib *.exp *.obj ntccrpc_c.c ntccrpc_s.c ntccrpc.h + + diff --git a/src/lib/ccapi/unit-test/t_ccache.c b/src/lib/ccapi/unit-test/t_ccache.c index 6ef33ea23d..175764e798 100644 --- a/src/lib/ccapi/unit-test/t_ccache.c +++ b/src/lib/ccapi/unit-test/t_ccache.c @@ -59,8 +59,8 @@ int main() { int i; cc_int32 code; - code = cci_ccache_new("The first", p1, cc_credentials_v4_v5, &c1); - code = cci_ccache_new("The 2nd", p2, cc_credentials_v4_v5, &c2); + code = ccs_ccache_new("The first", p1, cc_credentials_v4_v5, &c1); + code = ccs_ccache_new("The 2nd", p2, cc_credentials_v4_v5, &c2); cred1 = (cc_server_credentials_t*)malloc(sizeof(cc_server_credentials_t)); memset(cred1,0,sizeof(cc_server_credentials_t)); @@ -83,30 +83,30 @@ int main() { strncpy(cred2->creds.credentials.credentials_v4->principal, p1, strlen(p1)); cred3->creds.credentials.credentials_v5->client = p1; - code = cci_ccache_store_creds(c1, &cred1->creds); + code = ccs_ccache_store_creds(c1, &cred1->creds); printf("(c1, cred1) -> %d\n",code); - code = cci_ccache_store_creds(c1, &cred2->creds); + code = ccs_ccache_store_creds(c1, &cred2->creds); printf("(c1, cred2) -> %d\n",code); - code = cci_ccache_store_creds(c2, &cred3->creds); + code = ccs_ccache_store_creds(c2, &cred3->creds); printf("(c2, cred3) -> %d\n",code); - code = cci_ccache_store_creds(c1, &cred3->creds); + code = ccs_ccache_store_creds(c1, &cred3->creds); printf("(c1, cred3) -> %d\n",code); i = 0; - code = cci_ccache_move(c1, c2); - code = cci_ccache_destroy(c1); - code = cci_ccache_new_iterator(c2, &iterator); - while (cci_credentials_iterate_has_next(iterator)) { + code = ccs_ccache_move(c1, c2); + code = ccs_ccache_destroy(c1); + code = ccs_ccache_new_iterator(c2, &iterator); + while (ccs_credentials_iterate_has_next(iterator)) { i++; - code = cci_credentials_iterate_next(iterator, &node); + code = ccs_credentials_iterate_next(iterator, &node); stored_cred = (cc_server_credentials_t *)node->data; printf("%d %d %s\n", stored_cred->is_default, stored_cred->creds.version, stored_cred->creds.credentials.credentials_v4->principal); if (i == 1) { - code = cci_ccache_rem_creds(c2,&cred2->creds); + code = ccs_ccache_rem_creds(c2,&cred2->creds); printf("(c2 rem cred2) -> %d\n",code); } } diff --git a/src/lib/ccapi/unit-test/t_context.c b/src/lib/ccapi/unit-test/t_context.c index 9e35d9abf3..d76ff78d9a 100644 --- a/src/lib/ccapi/unit-test/t_context.c +++ b/src/lib/ccapi/unit-test/t_context.c @@ -68,10 +68,10 @@ int main() { int i; cc_int32 code; - code = cci_context_new(5, auth_info, session_info, &ctx); - code = cci_context_create_default_ccache(ctx, cc_credentials_v4, "Spike", &ccache); - code = cci_context_get_default_ccache_name(ctx, &name); - code = cci_context_open_ccache(ctx, name, &ccache); + code = ccs_context_new(5, auth_info, session_info, &ctx); + code = ccs_context_create_default_ccache(ctx, cc_credentials_v4, "Spike", &ccache); + code = ccs_context_get_default_ccache_name(ctx, &name); + code = ccs_context_open_ccache(ctx, name, &ccache); for (i = 0; i < 5; i++) { creds = (cc_credentials_union*)malloc(sizeof(cc_credentials_union)); @@ -79,32 +79,32 @@ int main() { creds->credentials.credentials_v4 = (cc_credentials_v4_t*)malloc(sizeof(cc_credentials_v4_t)); strcpy(creds->credentials.credentials_v4->principal, "Spike"); - code = cci_ccache_store_creds(ccache, creds); + code = ccs_ccache_store_creds(ccache, creds); } - code = cci_context_create_ccache(ctx, "ccache 2", cc_credentials_v4, "Jeff", &ccache); - code = cci_context_open_ccache(ctx, "ccache 2", &ccache); + code = ccs_context_create_ccache(ctx, "ccache 2", cc_credentials_v4_v5, "Jeff", &ccache); + code = ccs_context_open_ccache(ctx, "ccache 2", &ccache); for (i = 0; i < 5; i++) { creds = (cc_credentials_union*)malloc(sizeof(cc_credentials_union)); - creds->version = cc_credentials_v4; - creds->credentials.credentials_v4 = (cc_credentials_v4_t*)malloc(sizeof(cc_credentials_v4_t)); - strcpy(creds->credentials.credentials_v4->principal, "Jeff"); + creds->version = cc_credentials_v5; + creds->credentials.credentials_v5 = (cc_credentials_v5_t*)malloc(sizeof(cc_credentials_v5_t)); + strcpy(creds->credentials.credentials_v5->principal, "Jeff"); - cci_ccache_store_creds(ccache, creds); + ccs_ccache_store_creds(ccache, creds); } - code = cci_context_ccache_iterator(ctx, &ccache_iterator); - while (cci_ccache_iterate_has_next(ccache_iterator)) { - code = cci_ccache_iterate_next(ccache_iterator, &ccache_node); + code = ccs_context_ccache_iterator(ctx, &ccache_iterator); + while (ccs_ccache_iterate_has_next(ccache_iterator)) { + code = ccs_ccache_iterate_next(ccache_iterator, &ccache_node); ccache = (cc_server_ccache_t *)ccache_node->data; printf("%x for %s %s default = %d v %d\n", ccache, ccache->principal_v4, ccache->principal_v5, ccache->is_default, ccache->versions); - code = cci_ccache_new_iterator(ccache, &creds_iterator); - while (cci_credentials_iterate_has_next(creds_iterator)) { - code = cci_credentials_iterate_next(creds_iterator, &creds_node); + code = ccs_ccache_new_iterator(ccache, &creds_iterator); + while (ccs_credentials_iterate_has_next(creds_iterator)) { + code = ccs_credentials_iterate_next(creds_iterator, &creds_node); server_creds = (cc_server_credentials_t *)creds_node->data; printf("\t%s %d\n", server_creds->creds.credentials.credentials_v4->principal, diff --git a/src/lib/ccapi/unit-test/t_server.c b/src/lib/ccapi/unit-test/t_server.c index d4d9984661..d6093941ef 100644 --- a/src/lib/ccapi/unit-test/t_server.c +++ b/src/lib/ccapi/unit-test/t_server.c @@ -143,7 +143,7 @@ main(void) cc_session_info_t * session_info; cc_int32 code; - if ( cci_serv_initialize() != ccNoError ) + if ( ccs_serv_initialize() != ccNoError ) return 1; while ( 1 ) { @@ -163,7 +163,7 @@ main(void) code = obtain_session_info(&session_info); /* process message */ - code = cci_serv_process_msg(msg, auth_info, session_info, &resp); + code = ccs_serv_process_msg(msg, auth_info, session_info, &resp); /* flatten response */ code = cci_msg_flatten(resp, NULL); diff --git a/src/lib/ccapi/windows/NTMakefile b/src/lib/ccapi/windows/NTMakefile new file mode 100644 index 0000000000..f6fee6f687 --- /dev/null +++ b/src/lib/ccapi/windows/NTMakefile @@ -0,0 +1,35 @@ +!include + +CFLAGS = -I../include $(cdebug) $(cflags) $(cvarsmt) + +CCAPI_SERVER = ccapi_server.exe + +CCAPI_DLLFILE = krbcc32.dll + +WINLIBS = ws2_32.lib rpcrt4.lib $(guilibsdll) + +all: $(CCAPI_DLLFILE) $(CCAPI_SERVER) + +ntccrpc_c.c ntccrpc_s.c ntccrpc.h: ntccrpc.idl ntccrpc.acf + midl ntccrpc.idl /acf ntccrpc.acf + +CLIENT_OBJS = ntccrpc_c.obj client.obj dllmain.obj + +SERVER_OBJS = ntccrpc_s.obj server.obj + +CC_CLIENT_LIB = ..\client\cc_client.lib + +CC_COMMON_LIB = ..\common\cc_common.lib + +CC_SERVER_LIB = ..\server\cc_server.lib + +$(CCAPI_DLLFILE): $(CLIENT_OBJS) $(CC_CLIENT_LIB) $(CC_COMMON_LIB) + $(link) /NOLOGO /OUT:$@ $(ldebug) $(dlllflags) $(guilibsmt) -def:cacheapi.def $** $(WINLIBS) + +$(CCAPI_SERVER): $(SERVER_OBJS) $(CC_SERVER_LIB) $(CC_COMMON_LIB) + $(link) /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** $(WINLIBS) + +clean: + del *.exe *.dll *.lib *.exp *.obj ntccrpc_c.c ntccrpc_s.c ntccrpc.h + + diff --git a/src/lib/ccapi/windows/cacheapi.def b/src/lib/ccapi/windows/cacheapi.def new file mode 100644 index 0000000000..c54cc11068 --- /dev/null +++ b/src/lib/ccapi/windows/cacheapi.def @@ -0,0 +1,29 @@ +EXPORTS + ; ccapi v3 only exports one function + cc_initialize @14 + + ; ccapi v2 compatibility functions + cc_close @2 + cc_create @3 + cc_destroy @4 + cc_free_NC_info @5 + cc_free_creds @6 + cc_free_name @7 + cc_free_principal @8 + cc_get_NC_info @9 + cc_get_change_time @10 + cc_get_cred_version @11 + cc_get_name @12 + cc_get_principal @13 + cc_lock_request @15 + cc_open @16 + cc_remove_cred @17 + cc_seq_fetch_NCs_begin @18 + cc_seq_fetch_NCs_end @19 + cc_seq_fetch_NCs_next @20 + cc_seq_fetch_creds_begin @21 + cc_seq_fetch_creds_end @22 + cc_seq_fetch_creds_next @23 + cc_set_principal @24 + cc_shutdown @25 + cc_store @26 diff --git a/src/lib/ccapi/windows/client.c b/src/lib/ccapi/windows/client.c new file mode 100644 index 0000000000..e30801dab6 --- /dev/null +++ b/src/lib/ccapi/windows/client.c @@ -0,0 +1,141 @@ +#include +#include +#include +#include +#include "ntccrpc.h" +#include +#include "CredentialsCache.h" +#include "msg.h" + +static RPC_BINDING_HANDLE hRpcBinding; + +void * __RPC_USER MIDL_user_allocate(size_t s) { + return malloc(s); +} + +void __RPC_USER MIDL_user_free(void * p) { + free(p); +} + +int cc_rpc_init(void) { + RPC_STATUS status; + TCHAR * bindstring = NULL; + RPC_SECURITY_QOS sqos; + + status = RpcStringBindingCompose(NULL, + _T("ncalrpc"), + NULL, + NULL, + NULL, + &bindstring); + + if (status != RPC_S_OK) { + fprintf(stderr, "RpcStringBindingCompose failed: %d\n", + status); + return 1; + } + + status = RpcBindingFromStringBinding(bindstring, + &hRpcBinding); + + if (status != RPC_S_OK) { + fprintf(stderr, "RpcBindingFromStringBinding failed: %d\n", + status); + return 1; + } + + status = RpcStringFree(&bindstring); + + ZeroMemory(&sqos, sizeof(sqos)); + + sqos.Version = 1; + sqos.Capabilities = RPC_C_QOS_CAPABILITIES_DEFAULT; + sqos.IdentityTracking = RPC_C_QOS_IDENTITY_STATIC; + sqos.ImpersonationType = RPC_C_IMP_LEVEL_IMPERSONATE; + + status = RpcBindingSetAuthInfoEx(hRpcBinding, + NULL, + RPC_C_AUTHN_LEVEL_CALL, + RPC_C_AUTHN_WINNT, + NULL, + 0, + &sqos); + if (status != RPC_S_OK) { + fprintf(stderr, "RpcBindingSetAuthInfoEx failed: %d\n", + status); + return 1; + } + + return 0; +} + +int cc_rpc_cleanup(void) { + RPC_STATUS status; + + status = RpcBindingFree(&hRpcBinding); + + return 0; +} + +cc_int32 cci_set_thread_session_id(unsigned char * client_name, LUID luid) { + return 0; +} + +void cci_get_thread_session_id(unsigned char * client_name, int len, LUID *pluid) { + client_name[0] = '\0'; + pluid->HighPart = 0; + pluid->LowPart = 0; +} + + +/* __int32 ccapi_Message( + * [in] handle_t h, + * [string][in] unsigned char *client_name, + * [in] struct _LUID luid, + * [in] __int32 cb_buffer, + * [out] __int32 *cb_len, + * [size_is][string][out] unsigned char buffer[ ]); + */ + +cc_int32 cci_perform_rpc(cc_msg_t *request, cc_msg_t **response) +{ + cc_int32 code; + unsigned char client_name[256]; + LUID luid; + struct __LUID __luid; + unsigned char out_buf[MAXMSGLEN]; + __int32 out_len = MAXMSGLEN; + + if (cc_rpc_init()) + return -1; + + cci_get_thread_session_id(client_name, sizeof(client_name), &luid); + + __luid.HighPart = luid.HighPart; + __luid.LowPart = luid.LowPart; + + /* flatten response */ + code = cci_msg_flatten(request, NULL); + if (code) + goto cleanup; + + RpcTryExcept { + code = ccapi_Message(hRpcBinding, client_name, __luid, + request->flat, request->flat_len, + out_buf, &out_len); + } + RpcExcept(1) { + code = RpcExceptionCode(); + } + RpcEndExcept; + if (code) + goto cleanup; + + /* unflatten message */ + code = cci_msg_unflatten(out_buf, out_len, response); + if (code) + goto cleanup; + + cleanup: + return code; +} diff --git a/src/lib/ccapi/windows/dllmain.c b/src/lib/ccapi/windows/dllmain.c new file mode 100644 index 0000000000..6b4d6bfdd8 --- /dev/null +++ b/src/lib/ccapi/windows/dllmain.c @@ -0,0 +1,15 @@ +#include + +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, + LPVOID lpvReserved) +{ + switch (fdwReason) { + case DLL_PROCESS_ATTACH: + case DLL_THREAD_ATTACH: + case DLL_THREAD_DETACH: + case DLL_PROCESS_DETACH: + default: + return TRUE; + } +} + diff --git a/src/lib/ccapi/windows/ntccrpc.acf b/src/lib/ccapi/windows/ntccrpc.acf new file mode 100644 index 0000000000..77216a9eab --- /dev/null +++ b/src/lib/ccapi/windows/ntccrpc.acf @@ -0,0 +1,8 @@ +[ + explicit_handle +] + +interface portable_ccapi +{ + +} \ No newline at end of file diff --git a/src/lib/ccapi/windows/ntccrpc.idl b/src/lib/ccapi/windows/ntccrpc.idl new file mode 100644 index 0000000000..51ff898d9b --- /dev/null +++ b/src/lib/ccapi/windows/ntccrpc.idl @@ -0,0 +1,30 @@ +[ + uuid(0012a1de-f7ad-44b0-b597-8ba53159c6fa), + version(1.0), + pointer_default(unique) +] + +interface portable_ccapi +{ + const short MAXMSGLEN = 65536; + + // Locally Unique Identifier + // + + struct __LUID { + __int32 LowPart; + long HighPart; + }; + + + // The Generic CCAPI Message RPC + + __int32 ccapi_Message ( + [in] handle_t h, + [in, string] unsigned char * client_name, + [in] struct __LUID luid, + [in, length_is(in_len), size_is(MAXMSGLEN)] unsigned char in_buf[], + [in] __int32 in_len, + [out, length_is(*out_len), size_is(MAXMSGLEN)] unsigned char out_buf[], + [out] __int32 * out_len); +} diff --git a/src/lib/ccapi/windows/rpcsstest/NTMakefile b/src/lib/ccapi/windows/rpcsstest/NTMakefile new file mode 100644 index 0000000000..0e23307072 --- /dev/null +++ b/src/lib/ccapi/windows/rpcsstest/NTMakefile @@ -0,0 +1,24 @@ + +!include + +{}.c{}.obj: + $(CC) $(cdebug) $(cflags) /Fo"$@" /c $** + +EXECONLINK=link /NOLOGO $(conlibsmt) $(ldebug) $(conlflags) /OUT:$@ $** + +CLIENTEXE=csclient.exe + +SERVEREXE=csserver.exe + +SDKLIBS=rpcrt4.lib + +cstest_c.c cstest_s.c cstest.h: cstest.idl cstest.acf + midl cstest.idl /acf cstest.acf + +$(CLIENTEXE): client.obj cstest_c.obj + $(EXECONLINK) $(SDKLIBS) + +$(SERVEREXE): server.obj cstest_s.obj + $(EXECONLINK) $(SDKLIBS) + +all: $(SERVEREXE) $(CLIENTEXE) diff --git a/src/lib/ccapi/windows/rpcsstest/client.c b/src/lib/ccapi/windows/rpcsstest/client.c new file mode 100644 index 0000000000..a25e8d1ade --- /dev/null +++ b/src/lib/ccapi/windows/rpcsstest/client.c @@ -0,0 +1,87 @@ +#include +#include +#include +#include +#include"cstest.h" +#include + +void * __RPC_USER MIDL_user_allocate(size_t s) { + return malloc(s); +} + +void __RPC_USER MIDL_user_free(void * p) { + free(p); +} + +int main(int argc, char ** argv) { + RPC_STATUS status; + RPC_BINDING_HANDLE h; + TCHAR * bindstring = NULL; + RPC_SECURITY_QOS sqos; + char inbuf[256]; + char outbuf[256]; + long cb_out; + + status = RpcStringBindingCompose(NULL, + _T("ncalrpc"), + NULL, + NULL, + NULL, + &bindstring); + + if (status != RPC_S_OK) { + fprintf(stderr, "RpcStringBindingCompose failed: %d\n", + status); + return 1; + } + + status = RpcBindingFromStringBinding(bindstring, + &h); + + if (status != RPC_S_OK) { + fprintf(stderr, "RpcBindingFromStringBinding failed: %d\n", + status); + return 1; + } + + ZeroMemory(&sqos, sizeof(sqos)); + + sqos.Version = 1; + sqos.Capabilities = RPC_C_QOS_CAPABILITIES_DEFAULT; + sqos.IdentityTracking = RPC_C_QOS_IDENTITY_STATIC; + sqos.ImpersonationType = RPC_C_IMP_LEVEL_IMPERSONATE; + + status = RpcBindingSetAuthInfoEx(h, + NULL, + RPC_C_AUTHN_LEVEL_CALL, + RPC_C_AUTHN_WINNT, + NULL, + 0, + &sqos); + + if (status != RPC_S_OK) { + fprintf(stderr, "RpcBindingSetAuthInfoEx failed: %d\n", + status); + return 1; + } + + StringCbCopyA(inbuf, sizeof(inbuf), "Echo Test 1"); + StringCbCopyA(outbuf, sizeof(outbuf), "Blank blank blank"); + + printf("Before call: in[%s], out[%s]\n", inbuf, outbuf); + cb_out = 0; + + status = EchoString(h, inbuf, sizeof(outbuf), &cb_out, outbuf); + + if (status) { + printf("Call failed: status = %d\n", status); + } else { + printf("After call: out[%s], outlen[%d]\n", outbuf, cb_out); + } + + status = RpcBindingFree(&h); + + status = RpcStringFree(&bindstring); + + return 0; +} diff --git a/src/lib/ccapi/windows/rpcsstest/cstest.acf b/src/lib/ccapi/windows/rpcsstest/cstest.acf new file mode 100644 index 0000000000..3c2ae73aba --- /dev/null +++ b/src/lib/ccapi/windows/rpcsstest/cstest.acf @@ -0,0 +1,8 @@ +[ + explicit_handle +] + +interface ccapi_cstest +{ + +} \ No newline at end of file diff --git a/src/lib/ccapi/windows/rpcsstest/cstest.idl b/src/lib/ccapi/windows/rpcsstest/cstest.idl new file mode 100644 index 0000000000..c51b8ee829 --- /dev/null +++ b/src/lib/ccapi/windows/rpcsstest/cstest.idl @@ -0,0 +1,14 @@ +[ +uuid(c8b4a635-e9e4-4650-a073-b25610324950), + version(1.0), + pointer_default(unique) +] + +interface ccapi_cstest +{ + long EchoString([in] handle_t h, + [in, string] unsigned char * in_str, + [in] long cb_buffer, + [out] long * cb_len, + [out, string, size_is(cb_buffer)] unsigned char buffer[*]); +} diff --git a/src/lib/ccapi/windows/rpcsstest/server.c b/src/lib/ccapi/windows/rpcsstest/server.c new file mode 100644 index 0000000000..f127434b58 --- /dev/null +++ b/src/lib/ccapi/windows/rpcsstest/server.c @@ -0,0 +1,537 @@ +#include +#include +#include +#include +#include +#include"cstest.h" +#include + +#define SVCNAME "CCAPICSTest" + +SERVICE_STATUS_HANDLE h_service_status = NULL; +SERVICE_STATUS service_status; +FILE * logfile = NULL; + +void begin_log(void) { + char temppath[512]; + + temppath[0] = L'\0'; + + GetTempPathA(sizeof(temppath), temppath); + StringCbCatA(temppath, sizeof(temppath), "csserverconn.log"); + logfile = fopen(temppath, "w"); +} + +void end_log(void) { + if (logfile) { + fclose(logfile); + logfile = NULL; + } +} + +BOOL report_status(DWORD state, + DWORD exit_code, + DWORD wait_hint) { + static DWORD checkpoint = 1; + BOOL rv = TRUE; + + if (state == SERVICE_START_PENDING) + service_status.dwControlsAccepted = 0; + else + service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP; + + service_status.dwCurrentState = state; + service_status.dwWin32ExitCode = exit_code; + service_status.dwWaitHint = wait_hint; + + if (state == SERVICE_RUNNING || + state == SERVICE_STOPPED) + service_status.dwCheckPoint = 0; + else + service_status.dwCheckPoint = checkpoint++; + + rv = SetServiceStatus(h_service_status, &service_status); + + return rv; +} + +void service_start(DWORD argc, LPTSTR * argv) { + RPC_STATUS status; + RPC_BINDING_VECTOR * bv; + + status = RpcServerUseProtseq("ncalrpc", + RPC_C_PROTSEQ_MAX_REQS_DEFAULT, + NULL); + + if (status != RPC_S_OK) { + return; + } + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerRegisterIf(ccapi_cstest_v1_0_s_ifspec, + 0, 0); + + if (status != RPC_S_OK) + return; + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerInqBindings(&bv); + + if (status != RPC_S_OK) + return; + + status = RpcEpRegister(ccapi_cstest_v1_0_s_ifspec, + bv, 0, 0); + + if (status != RPC_S_OK) + return; + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerRegisterAuthInfo(NULL, + RPC_C_AUTHN_WINNT, + 0, 0); + + if (status != RPC_S_OK) + return; + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerListen(1, + RPC_C_LISTEN_MAX_CALLS_DEFAULT, + TRUE); + + if (status != RPC_S_OK) + return; + + report_status(SERVICE_RUNNING, NO_ERROR, 0); + + begin_log(); + + status = RpcMgmtWaitServerListen(); + + end_log(); + + RpcEpUnregister(ccapi_cstest_v1_0_s_ifspec, bv, 0); + + RpcBindingVectorFree(&bv); +} + +void service_stop(void) { + RpcMgmtStopServerListening(0); +} + +void * __RPC_USER MIDL_user_allocate(size_t s) { + return malloc(s); +} + +void __RPC_USER MIDL_user_free(void * p) { + free(p); +} + +typedef struct tag_client_info { + char client_name[512]; + LUID luid; +} client_info_t; + +RPC_STATUS check_auth(handle_t h, client_info_t * client_info) { + RPC_BINDING_HANDLE bh = (RPC_BINDING_HANDLE) h; + RPC_STATUS status; + HANDLE htoken = NULL; + char name[256]; + char domain[256]; + DWORD name_len; + DWORD domain_len; + SID_NAME_USE snu = 0; + + struct { + TOKEN_ORIGIN origin; + char pad[512]; + } torigin; + + struct { + TOKEN_OWNER owner; + char pad[4096]; + } towner; + + DWORD len; + + status = RpcImpersonateClient(bh); + + if (status != RPC_S_OK) + return status; + + if (!OpenThreadToken(GetCurrentThread(), + TOKEN_READ | TOKEN_QUERY_SOURCE, + FALSE, + &htoken)) { + status = GetLastError(); + goto _cleanup; + } + + len = 0; + + if (!GetTokenInformation(htoken, + TokenOrigin, + &torigin.origin, + sizeof(torigin), + &len)) { + status = GetLastError(); + goto _cleanup; + } + + if (!GetTokenInformation(htoken, + TokenOwner, + &towner.owner, + sizeof(towner), + &len)) { + status = GetLastError(); + goto _cleanup; + } + + + name_len = sizeof(name)/sizeof(name[0]); + domain_len = sizeof(domain)/sizeof(domain[0]); + + if (!LookupAccountSidA(NULL, + towner.owner.Owner, + name, + &name_len, + domain, + &domain_len, + &snu)) { + status = GetLastError(); + goto _cleanup; + } + + client_info->luid = torigin.origin.OriginatingLogonSession; + StringCbPrintfA(client_info->client_name, + sizeof(client_info->client_name), + "%s\\%s", domain, name); + + status = 0; + + _cleanup: + + RpcRevertToSelf(); + + return status; +} + +long EchoString( + /* [in] */ handle_t h, + /* [string][in] */ unsigned char *in_str, + /* [in] */ long cb_buffer, + /* [out] */ long *cb_len, + /* [size_is][string][out] */ unsigned char buffer[ ]) { + + size_t cb; + long rv = 0; + client_info_t client_info; + + rv = check_auth(h, &client_info); + + if (rv == 0 && logfile) { + fprintf(logfile, + "Client name [%s], LUID [%x:%x]\n", + client_info.client_name, + (client_info.luid.HighPart), + (client_info.luid.LowPart)); + fflush(logfile); + } + + if (!in_str) { + rv = 1; + if (cb_len) + *cb_len = 0; + if (buffer) + buffer[0] = '\0'; + } else { + if (FAILED(StringCbLengthA(in_str, 256, &cb))) { + rv = 2; + goto _exit_f; + } + + cb += sizeof(char); + + if (((long)cb) > cb_buffer) { + rv = 3; + goto _exit_f; + } + + *cb_len = cb; + + if (buffer) + StringCbCopyA(buffer, cb_buffer, in_str); + + rv = 0; + } + + _exit_f: + + return rv; +} + +void WINAPI service_control(DWORD ctrl_code) { + switch(ctrl_code) { + case SERVICE_CONTROL_STOP: + report_status(SERVICE_STOP_PENDING, NO_ERROR, 0); + service_stop(); + return; + + /* everything else falls through */ + } + + report_status(service_status.dwCurrentState, NO_ERROR, 0); +} + +void WINAPI service_main(DWORD argc, LPTSTR * argv) { + + h_service_status = RegisterServiceCtrlHandler( _T(SVCNAME), service_control); + + if (!h_service_status) + goto cleanup; + + ZeroMemory(&service_status, sizeof(service_status)); + + service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + service_status.dwServiceSpecificExitCode = 0; + + if (!report_status(SERVICE_START_PENDING, + NO_ERROR, + 3000)) + goto cleanup; + + service_start(argc, argv); + + cleanup: + + if (h_service_status) { + report_status(SERVICE_STOPPED, NO_ERROR, 0); + } +} + + +BOOL +IsInstalled() +{ + BOOL bResult = FALSE; + SC_HANDLE hSCM; + SC_HANDLE hService; + + // Open the Service Control Manager + hSCM = OpenSCManager( NULL, // local machine + NULL, // ServicesActive database + SC_MANAGER_ALL_ACCESS); // full access + if (hSCM) { + + // Try to open the service + hService = OpenService( hSCM, + SVCNAME, + SERVICE_QUERY_CONFIG); + if (hService) { + bResult = TRUE; + CloseServiceHandle(hService); + } + + CloseServiceHandle(hSCM); + } + + return bResult; +} + +BOOL +Install() +{ + char szFilePath[_MAX_PATH]; + SC_HANDLE hSCM; + SC_HANDLE hService; + TCHAR szKey[256]; + HKEY hKey = NULL; + DWORD dwData; + + // Open the Service Control Manager + hSCM = OpenSCManager( NULL, // local machine + NULL, // ServicesActive database + SC_MANAGER_ALL_ACCESS); // full access + if (!hSCM) + return FALSE; + + // Get the executable file path + GetModuleFileName(NULL, szFilePath, sizeof(szFilePath)); + + // Create the service + hService = CreateService( hSCM, + SVCNAME, + SVCNAME, + SERVICE_ALL_ACCESS, + SERVICE_WIN32_OWN_PROCESS, + SERVICE_AUTO_START, // start condition + SERVICE_ERROR_NORMAL, + szFilePath, + NULL, + NULL, + NULL, + NULL, + NULL); + if (!hService) { + CloseServiceHandle(hSCM); + return FALSE; + } + + // make registry entries to support logging messages + // Add the source name as a subkey under the Application + // key in the EventLog service portion of the registry. + StringCbCopyA(szKey, 256, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\IKSD"); + if (RegCreateKey(HKEY_LOCAL_MACHINE, szKey, &hKey) != ERROR_SUCCESS) { + CloseServiceHandle(hService); + CloseServiceHandle(hSCM); + return FALSE; + } + + // Add the Event ID message-file name to the 'EventMessageFile' subkey. + RegSetValueEx( hKey, + "EventMessageFile", + 0, + REG_EXPAND_SZ, + (CONST BYTE*)szFilePath, + strlen(szFilePath) + 1); + + // Set the supported types flags. + dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; + RegSetValueEx( hKey, + "TypesSupported", + 0, + REG_DWORD, + (CONST BYTE*)&dwData, + sizeof(DWORD)); + RegCloseKey(hKey); + + // LogEvent(EVENTLOG_INFORMATION_TYPE, EVMSG_INSTALLED, SVCNAME); + + // tidy up + CloseServiceHandle(hService); + CloseServiceHandle(hSCM); + return TRUE; +} + +BOOL +Uninstall() +{ + BOOL bResult = FALSE; + SC_HANDLE hService; + SC_HANDLE hSCM; + + // Open the Service Control Manager + hSCM = OpenSCManager( NULL, // local machine + NULL, // ServicesActive database + SC_MANAGER_ALL_ACCESS); // full access + if (!hSCM) + return FALSE; + + hService = OpenService( hSCM, + SVCNAME, + DELETE); + if (hService) { + if (DeleteService(hService)) { + // LogEvent(EVENTLOG_INFORMATION_TYPE, EVMSG_REMOVED, SVCNAME); + bResult = TRUE; + } else { + // LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_NOTREMOVED, SVCNAME); + } + CloseServiceHandle(hService); + } + + CloseServiceHandle(hSCM); + return bResult; +} + + +// Returns TRUE if it found an arg it recognised, FALSE if not +// Note: processing some arguments causes output to stdout to be generated. +BOOL +ParseStandardArgs(int argc, char* argv[]) +{ + char szFilePath[_MAX_PATH]; + + // See if we have any command line args we recognize + if (argc <= 1) + return FALSE; + + if ( _stricmp(argv[1], "-h") == 0 || + _stricmp(argv[1], "-?") == 0 || + _stricmp(argv[1], "/h") == 0 || + _stricmp(argv[1], "/?") == 0) { + + // + GetModuleFileName(NULL, szFilePath, sizeof(szFilePath)); + fprintf(stderr, "usage: %s [-v | -i | -u | -h]\r\n",szFilePath); + return TRUE; + } else if (_stricmp(argv[1], "-v") == 0 || + _stricmp(argv[1], "/v") == 0 ) { + + // Spit out version info + fprintf(stderr, "%s Version 0.1\n",_T(SVCNAME)); + fprintf(stderr, "The service is %s installed\n", + IsInstalled() ? "currently" : "not"); + return TRUE; // say we processed the argument + + } else if (_stricmp(argv[1], "-i") == 0 || + _stricmp(argv[1], "/i") == 0) { + + // Request to install. + if (IsInstalled()) { + fprintf(stderr, "%s is already installed\n", _T(SVCNAME)); + } else { + // Try and install the copy that's running + if (Install()) { + fprintf(stderr, "%s installed\n", _T(SVCNAME)); + } else { + fprintf(stderr, "%s failed to install. Error %d\n", _T(SVCNAME), GetLastError()); + } + } + return TRUE; // say we processed the argument + + } else if (_stricmp(argv[1], "-u") == 0 || + _stricmp(argv[1], "/u") == 0) { + + // Request to uninstall. + if (!IsInstalled()) { + fprintf(stderr, "%s is not installed\n", _T(SVCNAME)); + } else { + // Try and remove the copy that's installed + if (Uninstall()) { + // Get the executable file path + GetModuleFileName(NULL, szFilePath, sizeof(szFilePath)); + fprintf(stderr, "%s removed. (You must delete the file (%s) yourself.)\n" + _T(SVCNAME), szFilePath); + } else { + fprintf(stderr, "Could not remove %s. Error %d\n", _T(SVCNAME), GetLastError()); + } + } + return TRUE; // say we processed the argument + + } + + // Don't recognise the args + return FALSE; +} + +int main(int argc, char ** argv) { + + SERVICE_TABLE_ENTRY dispatch_table[] = { + { _T(SVCNAME), (LPSERVICE_MAIN_FUNCTION) service_main }, + { NULL, NULL } + }; + + if ( ParseStandardArgs(argc, argv) ) + return 0; + + if (!StartServiceCtrlDispatcher(dispatch_table)) { + fprintf(stderr, "Can't start service control dispatcher\n"); + } + + return 0; +} diff --git a/src/lib/ccapi/windows/server.c b/src/lib/ccapi/windows/server.c new file mode 100644 index 0000000000..ac4ab70abd --- /dev/null +++ b/src/lib/ccapi/windows/server.c @@ -0,0 +1,679 @@ + +#include +#include "msg.h" +#include "marshall.h" +#include "serv_ops.h" +#include "datastore.h" +#include +#include +#include +#include +#include +#include "ntccrpc.h" +#include + +#define SVCNAME "MIT_CCAPI_NT_Service" + +HANDLE hMainThread = 0; +HANDLE WaitToTerminate = 0; + +SERVICE_STATUS_HANDLE h_service_status = NULL; +SERVICE_STATUS service_status; +FILE * logfile = NULL; + +/* Log File */ +void begin_log(void) { + char temppath[512]; + + temppath[0] = L'\0'; + + GetTempPathA(sizeof(temppath), temppath); + StringCbCatA(temppath, sizeof(temppath), "mit_nt_ccapi.log"); + logfile = fopen(temppath, "w"); +} + +void end_log(void) { + if (logfile) { + fclose(logfile); + logfile = NULL; + } +} + +BOOL report_status(DWORD state, + DWORD exit_code, + DWORD wait_hint) { + static DWORD checkpoint = 1; + BOOL rv = TRUE; + + if (state == SERVICE_START_PENDING) + service_status.dwControlsAccepted = 0; + else + service_status.dwControlsAccepted = SERVICE_ACCEPT_STOP; + + service_status.dwCurrentState = state; + service_status.dwWin32ExitCode = exit_code; + service_status.dwWaitHint = wait_hint; + + if (state == SERVICE_RUNNING || + state == SERVICE_STOPPED) + service_status.dwCheckPoint = 0; + else + service_status.dwCheckPoint = checkpoint++; + + rv = SetServiceStatus(h_service_status, &service_status); + + return rv; +} + +void service_start(DWORD argc, LPTSTR * argv) { + RPC_STATUS status; + RPC_BINDING_VECTOR * bv; + + status = RpcServerUseProtseq("ncalrpc", + RPC_C_PROTSEQ_MAX_REQS_DEFAULT, + NULL); + + if (status != RPC_S_OK) { + if (logfile) fprintf(logfile, "service_start RpcServerUseProtseq = 0x%x\n", status); + goto cleanup; + } + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerRegisterIf(portable_ccapi_v1_0_s_ifspec, + 0, 0); + + if (status != RPC_S_OK) { + if (logfile) fprintf(logfile, "service_start RpcServerRegisterIf = 0x%x\n", status); + goto cleanup; + } + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerInqBindings(&bv); + + if (status != RPC_S_OK) { + if (logfile) fprintf(logfile, "service_start RpcServerInqBindings = 0x%x\n", status); + goto cleanup; + } + + status = RpcEpRegister(portable_ccapi_v1_0_s_ifspec, + bv, 0, 0); + + if (status != RPC_S_OK) { + if (logfile) fprintf(logfile, "service_start RpcEpRegister = 0x%x\n", status); + goto cleanup; + } + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerRegisterAuthInfo(NULL, + RPC_C_AUTHN_WINNT, + 0, 0); + + if (status != RPC_S_OK) { + if (logfile) fprintf(logfile, "service_start RpcServerRegisterAuthInfo = 0x%x\n", status); + goto cleanup; + } + + report_status(SERVICE_START_PENDING, NO_ERROR, 3000); + + status = RpcServerListen(2, + RPC_C_LISTEN_MAX_CALLS_DEFAULT, + TRUE); + + if (status != RPC_S_OK) { + if (logfile) fprintf(logfile, "service_start RpcServerListen = 0x%x\n", status); + goto cleanup; + } + + report_status(SERVICE_RUNNING, NO_ERROR, 0); + + + if (logfile) fprintf(logfile, "service_start calling RpcMgmtWaitServerListen\n"); + status = RpcMgmtWaitServerListen(); + if (logfile) fprintf(logfile, "service_start RpcMgmtWaitServerListen = 0x%x\n", status); + + cleanup: + RpcEpUnregister(portable_ccapi_v1_0_s_ifspec, bv, 0); + + RpcBindingVectorFree(&bv); +} + +void service_stop(void) { + if (logfile) fprintf(logfile, "service_stop\n"); + RpcMgmtStopServerListening(0); +} + +void * __RPC_USER MIDL_user_allocate(size_t s) { + return malloc(s); +} + +void __RPC_USER MIDL_user_free(void * p) { + free(p); +} + +typedef struct tag_client_info { + char client_name[512]; + LUID luid; +} client_info_t; + +int obtain_auth_info(client_info_t * client_info, cc_auth_info_t ** pauth_info) +{ + *pauth_info = (cc_auth_info_t *)malloc(sizeof(cc_auth_info_t)); + if ( !*pauth_info ) + return ccErrNoMem; + + (*pauth_info)->len = strlen(client_info->client_name) + 1; + (*pauth_info)->info = malloc((*pauth_info)->len); + if ( !(*pauth_info)->info ) { + free(*pauth_info); + return ccErrNoMem; + } + + memcpy((*pauth_info)->info, client_info->client_name, (*pauth_info)->len); + + return 0; +} + +void destroy_auth_info(cc_auth_info_t *auth_info) +{ + free(auth_info->info); + free(auth_info); +} + +int obtain_session_info(client_info_t * client_info, cc_session_info_t ** psession_info) +{ + *psession_info = (cc_session_info_t *)malloc(sizeof(cc_session_info_t)); + if ( !*psession_info ) + return ccErrNoMem; + + (*psession_info)->len = sizeof(LUID); + (*psession_info)->info = malloc((*psession_info)->len); + if ( !(*psession_info)->info ) { + free(*psession_info); + return ccErrNoMem; + } + + memcpy((*psession_info)->info, &client_info->luid, (*psession_info)->len); + + return 0; +} + +void destroy_session_info(cc_session_info_t *session_info) +{ + free(session_info->info); + free(session_info); +} + +RPC_STATUS check_auth(handle_t h, client_info_t * client_info) { + RPC_BINDING_HANDLE bh = (RPC_BINDING_HANDLE) h; + RPC_STATUS status; + HANDLE htoken = NULL; + char name[256]; + char domain[256]; + DWORD name_len; + DWORD domain_len; + SID_NAME_USE snu = 0; + + struct { + TOKEN_ORIGIN origin; + char pad[512]; + } torigin; + + struct { + TOKEN_OWNER owner; + char pad[4096]; + } towner; + + DWORD len; + + status = RpcImpersonateClient(bh); + + if (status != RPC_S_OK) + return status; + + if (!OpenThreadToken(GetCurrentThread(), + TOKEN_READ | TOKEN_QUERY_SOURCE, + FALSE, + &htoken)) { + status = GetLastError(); + goto _cleanup; + } + + len = 0; + + if (!GetTokenInformation(htoken, + TokenOrigin, + &torigin.origin, + sizeof(torigin), + &len)) { + status = GetLastError(); + goto _cleanup; + } + + if (!GetTokenInformation(htoken, + TokenOwner, + &towner.owner, + sizeof(towner), + &len)) { + status = GetLastError(); + goto _cleanup; + } + + + name_len = sizeof(name)/sizeof(name[0]); + domain_len = sizeof(domain)/sizeof(domain[0]); + + if (!LookupAccountSidA(NULL, + towner.owner.Owner, + name, + &name_len, + domain, + &domain_len, + &snu)) { + status = GetLastError(); + goto _cleanup; + } + + client_info->luid = torigin.origin.OriginatingLogonSession; + StringCbPrintfA(client_info->client_name, + sizeof(client_info->client_name), + "%s\\%s", domain, name); + + status = 0; + + _cleanup: + + RpcRevertToSelf(); + + return status; +} + +__int32 ccapi_Message( + /* [in] */ handle_t h, + /* [string][in] */ unsigned char *client_name, + /* [in] */ struct __LUID luid, + /* [size_is][length_is][in] */ unsigned char in_buf[], + /* [in] */ __int32 in_len, + /* [size_is][length_is][out] */ unsigned char out_buf[], + /* [out] */ __int32 *out_len) +{ + client_info_t client_info; + cc_msg_t * msg = NULL; + cc_msg_t * resp = NULL; + cc_auth_info_t * auth_info = NULL; + cc_session_info_t * session_info = NULL; + cc_int32 code; + + if (logfile) fprintf(logfile, "ccapi_Message\n"); + + if ( ccs_serv_initialize() != ccNoError ) { + code = ccErrServerUnavailable; + goto done; + } + + code = check_auth(h, &client_info); + if (code == 0) { + if (!strcmp("SYSTEM",client_info.client_name) && + client_info.luid.HighPart == 0 && + client_info.luid.LowPart == 0 && + client_name != NULL && + client_name[0] != '\0') { + StringCbPrintfA(client_info.client_name, + sizeof(client_info.client_name), + "%s", client_name); + client_info.luid.HighPart = luid.HighPart; + client_info.luid.LowPart = luid.LowPart; + } + } else { + code = ccErrServerCantBecomeUID; + goto done; + } + + /* allocate message */ + msg = (cc_msg_t *)malloc(sizeof(cc_msg_t)); + if (!msg) { + code = ccErrNoMem; + goto done; + } + + /* unflatten message */ + code = cci_msg_unflatten(in_buf, in_len, &msg); + if (code) + goto cleanup; + + /* obtain auth info */ + code = obtain_auth_info(&client_info, &auth_info); + if (code) + goto cleanup; + + /* obtain session info */ + code = obtain_session_info(&client_info, &session_info); + if (code) + goto cleanup; + + /* process message */ + code = ccs_serv_process_msg(msg, auth_info, session_info, &resp); + if (code) + goto cleanup; + + /* flatten response */ + code = cci_msg_flatten(resp, NULL); + if (code) + goto cleanup; + + /* send response */ + if (resp->flat_len > MAXMSGLEN) { + code = ccErrBadInternalMessage; + goto cleanup; + } + memcpy(out_buf, resp->flat, resp->flat_len); + *out_len = resp->flat_len; + code = ccNoError; + + cleanup: + if (auth_info) + destroy_auth_info(auth_info); + + if (session_info) + destroy_session_info(session_info); + + /* free message */ + if (msg) + cci_msg_destroy(msg); + + /* free response */ + if (resp) + cci_msg_destroy(resp); + + done: + return code ? -1 : 0; +} + +void WINAPI service_control(DWORD ctrl_code) { + switch(ctrl_code) { + case SERVICE_CONTROL_STOP: + report_status(SERVICE_STOP_PENDING, NO_ERROR, 0); + service_stop(); + return; + + /* everything else falls through */ + } + + report_status(service_status.dwCurrentState, NO_ERROR, 0); +} + +void WINAPI service_main(DWORD argc, LPTSTR * argv) { + + begin_log(); + + h_service_status = RegisterServiceCtrlHandler( _T(SVCNAME), service_control); + + if (!h_service_status) + goto cleanup; + + ZeroMemory(&service_status, sizeof(service_status)); + + service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS; + service_status.dwServiceSpecificExitCode = 0; + + if (!report_status(SERVICE_START_PENDING, + NO_ERROR, + 3000)) + goto cleanup; + + service_start(argc, argv); + + cleanup: + + if (h_service_status) { + report_status(SERVICE_STOPPED, NO_ERROR, 0); + } + + end_log(); +} + + +BOOL +IsInstalled() +{ + BOOL bResult = FALSE; + SC_HANDLE hSCM; + SC_HANDLE hService; + + // Open the Service Control Manager + hSCM = OpenSCManager( NULL, // local machine + NULL, // ServicesActive database + SC_MANAGER_ALL_ACCESS); // full access + if (hSCM) { + + // Try to open the service + hService = OpenService( hSCM, + SVCNAME, + SERVICE_QUERY_CONFIG); + if (hService) { + bResult = TRUE; + CloseServiceHandle(hService); + } + + CloseServiceHandle(hSCM); + } + + return bResult; +} + +BOOL +Install() +{ + char szFilePath[_MAX_PATH]; + SC_HANDLE hSCM; + SC_HANDLE hService; + TCHAR szKey[256]; + HKEY hKey = NULL; + DWORD dwData; + + // Open the Service Control Manager + hSCM = OpenSCManager( NULL, // local machine + NULL, // ServicesActive database + SC_MANAGER_ALL_ACCESS); // full access + if (!hSCM) + return FALSE; + + // Get the executable file path + GetModuleFileName(NULL, szFilePath, sizeof(szFilePath)); + + // Create the service + hService = CreateService( hSCM, + SVCNAME, + SVCNAME, + SERVICE_ALL_ACCESS, + SERVICE_WIN32_OWN_PROCESS, + SERVICE_AUTO_START, // start condition + SERVICE_ERROR_NORMAL, + szFilePath, + NULL, + NULL, + NULL, + NULL, + NULL); + if (!hService) { + CloseServiceHandle(hSCM); + return FALSE; + } + + // make registry entries to support logging messages + // Add the source name as a subkey under the Application + // key in the EventLog service portion of the registry. + StringCbCopyA(szKey, 256, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\IKSD"); + if (RegCreateKey(HKEY_LOCAL_MACHINE, szKey, &hKey) != ERROR_SUCCESS) { + CloseServiceHandle(hService); + CloseServiceHandle(hSCM); + return FALSE; + } + + // Add the Event ID message-file name to the 'EventMessageFile' subkey. + RegSetValueEx( hKey, + "EventMessageFile", + 0, + REG_EXPAND_SZ, + (CONST BYTE*)szFilePath, + strlen(szFilePath) + 1); + + // Set the supported types flags. + dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE; + RegSetValueEx( hKey, + "TypesSupported", + 0, + REG_DWORD, + (CONST BYTE*)&dwData, + sizeof(DWORD)); + RegCloseKey(hKey); + + // LogEvent(EVENTLOG_INFORMATION_TYPE, EVMSG_INSTALLED, SVCNAME); + + // tidy up + CloseServiceHandle(hService); + CloseServiceHandle(hSCM); + return TRUE; +} + +BOOL +Uninstall() +{ + BOOL bResult = FALSE; + SC_HANDLE hService; + SC_HANDLE hSCM; + + // Open the Service Control Manager + hSCM = OpenSCManager( NULL, // local machine + NULL, // ServicesActive database + SC_MANAGER_ALL_ACCESS); // full access + if (!hSCM) + return FALSE; + + hService = OpenService( hSCM, + _T(SVCNAME), + DELETE); + if (hService) { + if (DeleteService(hService)) { + // LogEvent(EVENTLOG_INFORMATION_TYPE, EVMSG_REMOVED, SVCNAME); + bResult = TRUE; + } else { + // LogEvent(EVENTLOG_ERROR_TYPE, EVMSG_NOTREMOVED, SVCNAME); + } + CloseServiceHandle(hService); + } + + CloseServiceHandle(hSCM); + return bResult; +} + + +// Returns TRUE if it found an arg it recognised, FALSE if not +// Note: processing some arguments causes output to stdout to be generated. +BOOL +ParseStandardArgs(int argc, char* argv[]) +{ + char szFilePath[_MAX_PATH]="not a file name"; + + // See if we have any command line args we recognize + if (argc <= 1) + return FALSE; + + if ( _stricmp(argv[1], "-h") == 0 || + _stricmp(argv[1], "-?") == 0 || + _stricmp(argv[1], "/h") == 0 || + _stricmp(argv[1], "/?") == 0) { + + // + GetModuleFileNameA(NULL, szFilePath, sizeof(szFilePath)); + fprintf(stderr, "usage: %s [-v | -i | -u | -h]\r\n",szFilePath); + return TRUE; + } else if (_stricmp(argv[1], "-v") == 0 || + _stricmp(argv[1], "/v") == 0 ) { + + // Spit out version info + fprintf(stderr, "%s Version 0.1\n",_T(SVCNAME)); + fprintf(stderr, "The service is %s installed\n", + IsInstalled() ? "currently" : "not"); + return TRUE; // say we processed the argument + + } else if (_stricmp(argv[1], "-i") == 0 || + _stricmp(argv[1], "/i") == 0) { + + // Request to install. + if (IsInstalled()) { + fprintf(stderr, "%s is already installed\n", _T(SVCNAME)); + } else { + // Try and install the copy that's running + if (Install()) { + fprintf(stderr, "%s installed\n", _T(SVCNAME)); + } else { + fprintf(stderr, "%s failed to install. Error %d\n", _T(SVCNAME), GetLastError()); + } + } + return TRUE; // say we processed the argument + + } else if (_stricmp(argv[1], "-u") == 0 || + _stricmp(argv[1], "/u") == 0) { + + // Request to uninstall. + if (!IsInstalled()) { + fprintf(stderr, "%s is not installed\n", _T(SVCNAME)); + } else { + // Try and remove the copy that's installed + if (Uninstall()) { + // Get the executable file path + GetModuleFileNameA(NULL, szFilePath, sizeof(szFilePath)); + fprintf(stderr, "%s removed. (You must delete the file (%s) yourself.)\n", + _T(SVCNAME), szFilePath); + } else { + fprintf(stderr, "Could not remove %s. Error %d\n", _T(SVCNAME), GetLastError()); + } + } + return TRUE; // say we processed the argument + + } + + // Don't recognise the args + return FALSE; +} + +DWORD __stdcall Main_thread(void* notUsed) +{ + char * argv[2] = {SVCNAME, NULL}; + begin_log(); + service_start(1, (LPTSTR*)argv); + end_log(); + return(0); +} + +int main(int argc, char ** argv) { + SERVICE_TABLE_ENTRY dispatch_table[] = { + { _T(SVCNAME), (LPSERVICE_MAIN_FUNCTION) service_main }, + { NULL, NULL } + }; + + if ( ParseStandardArgs(argc, argv) ) + return 0; + + if (!StartServiceCtrlDispatcher(dispatch_table)) { + LONG status = GetLastError(); + if (status == ERROR_FAILED_SERVICE_CONTROLLER_CONNECT) + { + DWORD tid; + hMainThread = CreateThread(NULL, 0, Main_thread, 0, 0, &tid); + + printf("Hit to terminate MIT CCAPI Server\n"); + getchar(); + service_stop(); + } + } + + if ( hMainThread ) { + WaitForSingleObject( hMainThread, INFINITE ); + CloseHandle( hMainThread ); + } + return 0; +} diff --git a/src/lib/crypto/Makefile.in b/src/lib/crypto/Makefile.in index 55a7950907..681c1a15dd 100644 --- a/src/lib/crypto/Makefile.in +++ b/src/lib/crypto/Makefile.in @@ -354,8 +354,8 @@ check-windows:: cd .. -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/crypto/aes/Makefile.in b/src/lib/crypto/aes/Makefile.in index 417a2b6247..917b751df0 100644 --- a/src/lib/crypto/aes/Makefile.in +++ b/src/lib/crypto/aes/Makefile.in @@ -68,7 +68,7 @@ clean-unix:: clean-libobjs clean:: -$(RM) aes-gen aes-gen.o vt.txt vk.txt kresults.out aes-test aes-test.o -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/crypto/arcfour/Makefile.in b/src/lib/crypto/arcfour/Makefile.in index 0311d1a2d1..2b461f00a9 100644 --- a/src/lib/crypto/arcfour/Makefile.in +++ b/src/lib/crypto/arcfour/Makefile.in @@ -36,7 +36,7 @@ depend:: $(SRCS) clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/crypto/crc32/Makefile.in b/src/lib/crypto/crc32/Makefile.in index e16171bdd9..ca0d031899 100644 --- a/src/lib/crypto/crc32/Makefile.in +++ b/src/lib/crypto/crc32/Makefile.in @@ -37,7 +37,7 @@ t_crc: t_crc.o crc32.o $(SUPPORT_DEPLIB) $(CC_LINK) -o $@ t_crc.o crc32.o $(SUPPORT_LIB) -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/crypto/des/Makefile.in b/src/lib/crypto/des/Makefile.in index d249976250..b6f293cee5 100644 --- a/src/lib/crypto/des/Makefile.in +++ b/src/lib/crypto/des/Makefile.in @@ -91,7 +91,7 @@ clean:: clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/crypto/dk/Makefile.in b/src/lib/crypto/dk/Makefile.in index baa93563f5..58a95d4c27 100644 --- a/src/lib/crypto/dk/Makefile.in +++ b/src/lib/crypto/dk/Makefile.in @@ -48,7 +48,7 @@ depend:: $(SRCS) clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/crypto/enc_provider/Makefile.in b/src/lib/crypto/enc_provider/Makefile.in index 8ac9da7185..e26fde5595 100644 --- a/src/lib/crypto/enc_provider/Makefile.in +++ b/src/lib/crypto/enc_provider/Makefile.in @@ -38,7 +38,7 @@ depend:: $(SRCS) clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/crypto/hash_provider/Makefile.in b/src/lib/crypto/hash_provider/Makefile.in index 7878c97888..d879b40297 100644 --- a/src/lib/crypto/hash_provider/Makefile.in +++ b/src/lib/crypto/hash_provider/Makefile.in @@ -33,7 +33,7 @@ depend:: $(SRCS) clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/crypto/keyhash_provider/Makefile.in b/src/lib/crypto/keyhash_provider/Makefile.in index a3c5017ccd..7e3bc03aa5 100644 --- a/src/lib/crypto/keyhash_provider/Makefile.in +++ b/src/lib/crypto/keyhash_provider/Makefile.in @@ -52,7 +52,7 @@ clean-unix:: clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/crypto/md4/Makefile.in b/src/lib/crypto/md4/Makefile.in index 7bb87dce78..c2f2d7b6fc 100644 --- a/src/lib/crypto/md4/Makefile.in +++ b/src/lib/crypto/md4/Makefile.in @@ -54,7 +54,7 @@ clean:: clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/crypto/md5/Makefile.in b/src/lib/crypto/md5/Makefile.in index e915e9e8a8..ab250951e7 100644 --- a/src/lib/crypto/md5/Makefile.in +++ b/src/lib/crypto/md5/Makefile.in @@ -44,7 +44,7 @@ clean:: clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/crypto/old/Makefile.in b/src/lib/crypto/old/Makefile.in index 006183db6f..d4db7a237f 100644 --- a/src/lib/crypto/old/Makefile.in +++ b/src/lib/crypto/old/Makefile.in @@ -31,7 +31,7 @@ depend:: $(SRCS) clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/crypto/raw/Makefile.in b/src/lib/crypto/raw/Makefile.in index c2389e1be2..d70493b096 100644 --- a/src/lib/crypto/raw/Makefile.in +++ b/src/lib/crypto/raw/Makefile.in @@ -29,7 +29,7 @@ depend:: $(SRCS) clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/crypto/sha1/Makefile.in b/src/lib/crypto/sha1/Makefile.in index 49ec4437f9..3113b8e4e4 100644 --- a/src/lib/crypto/sha1/Makefile.in +++ b/src/lib/crypto/sha1/Makefile.in @@ -49,7 +49,7 @@ clean-unix:: clean-libobjs t_shs3: t_shs3.o shs.o $(SUPPORT_DEPLIB) $(CC_LINK) -o t_shs3 t_shs3.o shs.o $(SUPPORT_LIB) -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/crypto/yarrow/Makefile.in b/src/lib/crypto/yarrow/Makefile.in index 9610636e09..ccdeb6cd0d 100644 --- a/src/lib/crypto/yarrow/Makefile.in +++ b/src/lib/crypto/yarrow/Makefile.in @@ -35,7 +35,7 @@ depend:: $(SRCS) clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/des425/Makefile.in b/src/lib/des425/Makefile.in index 61489fff6e..1289be32fd 100644 --- a/src/lib/des425/Makefile.in +++ b/src/lib/des425/Makefile.in @@ -109,8 +109,8 @@ clean-unix:: clean-liblinks clean-libs clean-libobjs install-unix:: install-libs -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/gssapi/Makefile.in b/src/lib/gssapi/Makefile.in index 03fc695b2f..a18159e3a1 100644 --- a/src/lib/gssapi/Makefile.in +++ b/src/lib/gssapi/Makefile.in @@ -6,8 +6,8 @@ LOCAL_SUBDIRS= generic mechglue krb5 spnego DEFS= ##DOSLIBNAME=$(OUTPRE)gssapi.lib -##DOSOBJFILELIST=@$(OUTPRE)generic.lst @$(OUTPRE)krb5.lst @$(OUTPRE)gssapi.lst -##DOSOBJFILEDEP=$(OUTPRE)generic.lst $(OUTPRE)krb5.lst $(OUTPRE)gssapi.lst +##DOSOBJFILELIST=@$(OUTPRE)mechglue.lst @$(OUTPRE)spnego.lst @$(OUTPRE)generic.lst @$(OUTPRE)krb5.lst @$(OUTPRE)gssapi.lst +##DOSOBJFILEDEP=$(OUTPRE)mechglue.lst $(OUTPRE)spnego.lst $(OUTPRE)generic.lst $(OUTPRE)krb5.lst $(OUTPRE)gssapi.lst ##DOSOBJFILE=$(OUTPRE)gssapi.lst ##DOSLIBOBJS=$(OBJS) @@ -30,7 +30,7 @@ LIBMINOR=2 LIBINITFUNC=gssint_lib_init LIBFINIFUNC=gssint_lib_fini STOBJLISTS=OBJS.ST generic/OBJS.ST mechglue/OBJS.ST krb5/OBJS.ST spnego/OBJS.ST -SUBDIROBJLISTS=generic/OBJS.ST mechglue/OBJS.ST krb5/OBJS.ST +SUBDIROBJLISTS=generic/OBJS.ST mechglue/OBJS.ST krb5/OBJS.ST spnego/OBJS.ST SHLIB_EXPDEPS=\ $(KRB5_DEPLIB) $(CRYPTO_DEPLIB) $(SUPPORT_DEPLIB) $(COM_ERR_DEPLIB) SHLIB_EXPLIBS=-lkrb5 -lk5crypto -lcom_err $(SUPPORT_LIB) $(DL_LIB) $(LIBS) @@ -38,15 +38,29 @@ SHLIB_DIRS=-L$(TOPLIBD) SHLIB_RDIRS=$(KRB5_LIBDIR) RELDIR=gssapi -all-unix:: all-liblinks +all-unix:: all-liblinks @MAINT@ verify-calling-conventions-gssapi install-unix:: install-libs -clean-unix:: clean-liblinks clean-libs clean-libobjs +clean-unix:: clean-liblinks clean-libs clean-libobjs clean-misc-unix clean-windows:: $(RM) gssapi.lib gssapi.bak +clean-misc-unix: + $(RM) merged-gssapi-header.h + +EHDRDIR=$(BUILDTOP)$(S)include$(S)gssapi +EXPORTED_HEADERS= \ + $(EHDRDIR)$(S)gssapi_krb5.h \ + $(EHDRDIR)$(S)gssapi_generic.h \ + $(EHDRDIR)$(S)gssapi.h +merged-gssapi-header.h: $(EXPORTED_HEADERS) + cat $(EXPORTED_HEADERS) > merged.tmp + $(MV) merged.tmp merged-gssapi-header.h +verify-calling-conventions-gssapi: merged-gssapi-header.h + $(PERL) -w $(SRCTOP)/util/def-check.pl merged-gssapi-header.h $(srcdir)/../gssapi32.def + all-windows:: cd generic @echo Making in gssapi\generic @@ -54,9 +68,12 @@ all-windows:: cd ..\krb5 @echo Making in gssapi\krb5 $(MAKE) -$(MFLAGS) -# cd ..\mechglue -# @echo Making in gssapi\mechglue -# $(MAKE) -$(MFLAGS) + cd ..\mechglue + @echo Making in gssapi\mechglue + $(MAKE) -$(MFLAGS) + cd ..\spnego + @echo Making in gssapi\spnego + $(MAKE) -$(MFLAGS) cd .. clean-windows:: @@ -66,9 +83,12 @@ clean-windows:: cd ..\krb5 @echo Making clean in gssapi\krb5 $(MAKE) -$(MFLAGS) clean -# cd ..\mechglue -# @echo Making clean in gssapi\mechglue -# $(MAKE) -$(MFLAGS) clean + cd ..\mechglue + @echo Making clean in gssapi\mechglue + $(MAKE) -$(MFLAGS) clean + cd ..\spnego + @echo Making clean in gssapi\spnego + $(MAKE) -$(MFLAGS) clean cd .. @echo Making clean in gssapi @@ -110,13 +130,13 @@ clean-windows:: # appears to be properly serializing the subdir processing and local # compiles... so far. ##DOS##!if 0 -$(BUILDTOP)/include/gssapi/gssapi.h generic/gssapi.h krb5/gssapi_err_krb5.h generic/gssapi_err_generic.h krb5/gssapi_krb5.h: all-recurse +$(EXPORTED_HEADERS) generic/gssapi.h krb5/gssapi_err_krb5.h generic/gssapi_err_generic.h krb5/gssapi_krb5.h: all-recurse : $@ updated by recursion rule ##DOS##!endif -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/gssapi/generic/Makefile.in b/src/lib/gssapi/generic/Makefile.in index 305a32589a..a9581f2d45 100644 --- a/src/lib/gssapi/generic/Makefile.in +++ b/src/lib/gssapi/generic/Makefile.in @@ -142,7 +142,7 @@ install-headers-unix install:: gssapi.h depend:: $(ETSRCS) -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/gssapi/gss_libinit.c b/src/lib/gssapi/gss_libinit.c index 16031e26ef..f075fe481e 100644 --- a/src/lib/gssapi/gss_libinit.c +++ b/src/lib/gssapi/gss_libinit.c @@ -40,9 +40,11 @@ int gssint_lib_init(void) err = k5_key_register(K5_KEY_GSS_KRB5_CCACHE_NAME, free); if (err) return err; +#ifndef _WIN32 err = k5_mutex_finish_init(&kg_kdc_flag_mutex); if (err) return err; +#endif return k5_mutex_finish_init(&kg_vdb.mutex); } @@ -64,7 +66,9 @@ void gssint_lib_fini(void) 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); +#ifndef _WIN32 k5_mutex_destroy(&kg_kdc_flag_mutex); +#endif k5_mutex_destroy(&gssint_krb5_keytab_lock); gssint_mechglue_fini(); } diff --git a/src/lib/gssapi/krb5/Makefile.in b/src/lib/gssapi/krb5/Makefile.in index 7f6b80034e..2d3368a883 100644 --- a/src/lib/gssapi/krb5/Makefile.in +++ b/src/lib/gssapi/krb5/Makefile.in @@ -235,7 +235,7 @@ includes:: gssapi_krb5.h install:: -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/gssapi/krb5/init_sec_context.c b/src/lib/gssapi/krb5/init_sec_context.c index 6d27fd33cb..81b49f2c73 100644 --- a/src/lib/gssapi/krb5/init_sec_context.c +++ b/src/lib/gssapi/krb5/init_sec_context.c @@ -970,29 +970,37 @@ krb5_gss_init_sec_context(minor_status, claimant_cred_handle, return(major_status); } +#ifndef _WIN32 k5_mutex_t kg_kdc_flag_mutex = K5_MUTEX_PARTIAL_INITIALIZER; static int kdc_flag = 0; +#endif krb5_error_code krb5_gss_init_context (krb5_context *ctxp) { krb5_error_code err; +#ifndef _WIN32 int is_kdc; +#endif err = gssint_initialize_library(); if (err) return err; +#ifndef _WIN32 err = k5_mutex_lock(&kg_kdc_flag_mutex); if (err) return err; is_kdc = kdc_flag; k5_mutex_unlock(&kg_kdc_flag_mutex); + if (is_kdc) return krb5int_init_context_kdc(ctxp); - else - return krb5_init_context(ctxp); +#endif + + return krb5_init_context(ctxp); } +#ifndef _WIN32 krb5_error_code krb5_gss_use_kdc_context() { @@ -1008,3 +1016,5 @@ krb5_gss_use_kdc_context() k5_mutex_unlock(&kg_kdc_flag_mutex); return 0; } +#endif + diff --git a/src/lib/gssapi/krb5/krb5_gss_glue.c b/src/lib/gssapi/krb5/krb5_gss_glue.c index 758cfbcb0f..77cf0da5ee 100644 --- a/src/lib/gssapi/krb5/krb5_gss_glue.c +++ b/src/lib/gssapi/krb5/krb5_gss_glue.c @@ -366,8 +366,6 @@ static OM_uint32 k5glue_validate_cred k5glue_inquire_context, \ k5glue_internal_release_oid, \ k5glue_wrap_size_limit, \ - NULL, /* pname_to_uid */ \ - NULL, /* userok */ \ k5glue_export_name, \ NULL /* store_cred */ @@ -396,7 +394,7 @@ static gss_mechanism krb5_mech_configs[] = { #ifdef MS_BUG_TEST static gss_mechanism krb5_mech_configs_hack[] = { &krb5_mechanism, &krb5_mechanism_old, NULL -} +}; #endif #if 1 diff --git a/src/lib/gssapi/libgssapi_krb5.exports b/src/lib/gssapi/libgssapi_krb5.exports index eb7dce968d..2d6199cde4 100644 --- a/src/lib/gssapi/libgssapi_krb5.exports +++ b/src/lib/gssapi/libgssapi_krb5.exports @@ -68,43 +68,6 @@ gss_verify gss_verify_mic gss_wrap gss_wrap_size_limit -krb5_gss_accept_sec_context -krb5_gss_acquire_cred -krb5_gss_add_cred -krb5_gss_canonicalize_name -krb5_gss_compare_name -krb5_gss_context_time -krb5_gss_convert_static_mech_oid krb5_gss_dbg_client_expcreds -krb5_gss_delete_sec_context -krb5_gss_display_name -krb5_gss_display_status -krb5_gss_duplicate_name -krb5_gss_export_name -krb5_gss_export_sec_context -krb5_gss_get_mic -krb5_gss_import_name -krb5_gss_import_sec_context -krb5_gss_indicate_mechs -krb5_gss_init_sec_context -krb5_gss_inquire_context -krb5_gss_inquire_cred -krb5_gss_inquire_cred_by_mech -krb5_gss_inquire_names_for_mech -krb5_gss_oid_array -krb5_gss_process_context_token krb5_gss_register_acceptor_identity -krb5_gss_release_cred -krb5_gss_release_name -krb5_gss_release_oid -krb5_gss_seal -krb5_gss_ser_init -krb5_gss_sign -krb5_gss_unseal -krb5_gss_unwrap -krb5_gss_validate_cred -krb5_gss_verify -krb5_gss_verify_mic -krb5_gss_wrap -krb5_gss_wrap_size_limit krb5_gss_use_kdc_context diff --git a/src/lib/gssapi/mechglue/Makefile.in b/src/lib/gssapi/mechglue/Makefile.in index 7d1c6136ce..d1c137ac2b 100644 --- a/src/lib/gssapi/mechglue/Makefile.in +++ b/src/lib/gssapi/mechglue/Makefile.in @@ -6,7 +6,8 @@ LOCALINCLUDES = -I. -I$(srcdir) -I$(srcdir)/.. -I../generic -I$(srcdir)/../gener DEFS= ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\$(OUTPRE)gssapi.$(LIBEXT) +##DOS##PREFIXDIR=mechglue +##DOS##OBJFILE=..\$(OUTPRE)mechglue.lst ##DOS##DLL_EXP_TYPE=GSS @@ -41,12 +42,43 @@ SRCS = \ $(srcdir)/g_sign.c \ $(srcdir)/g_store_cred.c \ $(srcdir)/g_unseal.c \ - $(srcdir)/g_userok.c \ - $(srcdir)/g_utils.c \ $(srcdir)/g_verify.c \ - $(srcdir)/gssd_pname_to_uid.c \ $(srcdir)/oid_ops.c +OBJS = \ + $(OUTPRE)g_accept_sec_context.$(OBJEXT) \ + $(OUTPRE)g_acquire_cred.$(OBJEXT) \ + $(OUTPRE)g_canon_name.$(OBJEXT) \ + $(OUTPRE)g_compare_name.$(OBJEXT) \ + $(OUTPRE)g_context_time.$(OBJEXT) \ + $(OUTPRE)g_delete_sec_context.$(OBJEXT) \ + $(OUTPRE)g_dsp_name.$(OBJEXT) \ + $(OUTPRE)g_dsp_status.$(OBJEXT) \ + $(OUTPRE)g_dup_name.$(OBJEXT) \ + $(OUTPRE)g_exp_sec_context.$(OBJEXT) \ + $(OUTPRE)g_export_name.$(OBJEXT) \ + $(OUTPRE)g_glue.$(OBJEXT) \ + $(OUTPRE)g_imp_name.$(OBJEXT) \ + $(OUTPRE)g_imp_sec_context.$(OBJEXT) \ + $(OUTPRE)g_init_sec_context.$(OBJEXT) \ + $(OUTPRE)g_initialize.$(OBJEXT) \ + $(OUTPRE)g_inq_context.$(OBJEXT) \ + $(OUTPRE)g_inq_cred.$(OBJEXT) \ + $(OUTPRE)g_inq_names.$(OBJEXT) \ + $(OUTPRE)g_mechname.$(OBJEXT) \ + $(OUTPRE)g_oid_ops.$(OBJEXT) \ + $(OUTPRE)g_process_context.$(OBJEXT) \ + $(OUTPRE)g_rel_buffer.$(OBJEXT) \ + $(OUTPRE)g_rel_cred.$(OBJEXT) \ + $(OUTPRE)g_rel_name.$(OBJEXT) \ + $(OUTPRE)g_rel_oid_set.$(OBJEXT) \ + $(OUTPRE)g_seal.$(OBJEXT) \ + $(OUTPRE)g_sign.$(OBJEXT) \ + $(OUTPRE)g_store_cred.$(OBJEXT) \ + $(OUTPRE)g_unseal.$(OBJEXT) \ + $(OUTPRE)g_verify.$(OBJEXT) \ + $(OUTPRE)oid_ops.$(OBJEXT) + STLIBOBJS = \ g_accept_sec_context.o \ g_acquire_cred.o \ @@ -78,17 +110,18 @@ STLIBOBJS = \ g_sign.o \ g_store_cred.o \ g_unseal.o \ - g_userok.o \ - g_utils.o \ g_verify.o \ - gssd_pname_to_uid.o \ oid_ops.o EHDRDIR= $(BUILDTOP)$(S)include$(S)gssapi EXPORTED_HEADERS = mechglue.h +$(OBJS): $(EXPORTED_HEADERS) + all-unix:: all-libobjs +##DOS##LIBOBJS = $(OBJS) + clean-unix:: clean-libobjs # Krb5InstallHeaders($(EXPORTED_HEADERS), $(KRB5_INCDIR)/krb5) @@ -100,7 +133,7 @@ install:: includes:: -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # # Makefile dependencies follow. This must be the last section in @@ -200,8 +233,8 @@ g_initialize.so g_initialize.po $(OUTPRE)g_initialize.$(OBJEXT): \ $(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/gssapi/gssapi.h \ $(COM_ERR_DEPS) $(SRCTOP)/include/k5-platform.h $(SRCTOP)/include/k5-thread.h \ $(srcdir)/../generic/gssapiP_generic.h $(srcdir)/../generic/gssapi_generic.h \ - ../generic/gssapi_err_generic.h g_initialize.c mechglue.h \ - mglueP.h + $(srcdir)/../gss_libinit.h ../generic/gssapi.h ../generic/gssapi_err_generic.h \ + g_initialize.c mechglue.h mglueP.h g_inq_context.so g_inq_context.po $(OUTPRE)g_inq_context.$(OBJEXT): \ $(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/gssapi/gssapi.h \ $(COM_ERR_DEPS) $(SRCTOP)/include/k5-platform.h $(SRCTOP)/include/k5-thread.h \ @@ -286,26 +319,12 @@ g_unseal.so g_unseal.po $(OUTPRE)g_unseal.$(OBJEXT): \ $(srcdir)/../generic/gssapiP_generic.h $(srcdir)/../generic/gssapi_generic.h \ ../generic/gssapi_err_generic.h g_unseal.c mechglue.h \ mglueP.h -g_userok.so g_userok.po $(OUTPRE)g_userok.$(OBJEXT): \ - $(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/gssapi/gssapi.h \ - $(COM_ERR_DEPS) $(SRCTOP)/include/k5-platform.h $(SRCTOP)/include/k5-thread.h \ - $(srcdir)/../generic/gssapiP_generic.h $(srcdir)/../generic/gssapi_generic.h \ - ../generic/gssapi_err_generic.h g_userok.c mechglue.h \ - mglueP.h -g_utils.so g_utils.po $(OUTPRE)g_utils.$(OBJEXT): $(BUILDTOP)/include/gssapi/gssapi.h \ - g_utils.c g_verify.so g_verify.po $(OUTPRE)g_verify.$(OBJEXT): \ $(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/gssapi/gssapi.h \ $(COM_ERR_DEPS) $(SRCTOP)/include/k5-platform.h $(SRCTOP)/include/k5-thread.h \ $(srcdir)/../generic/gssapiP_generic.h $(srcdir)/../generic/gssapi_generic.h \ ../generic/gssapi_err_generic.h g_verify.c mechglue.h \ mglueP.h -gssd_pname_to_uid.so gssd_pname_to_uid.po $(OUTPRE)gssd_pname_to_uid.$(OBJEXT): \ - $(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/gssapi/gssapi.h \ - $(COM_ERR_DEPS) $(SRCTOP)/include/k5-platform.h $(SRCTOP)/include/k5-thread.h \ - $(srcdir)/../generic/gssapiP_generic.h $(srcdir)/../generic/gssapi_generic.h \ - ../generic/gssapi_err_generic.h gssd_pname_to_uid.c \ - mechglue.h mglueP.h oid_ops.so oid_ops.po $(OUTPRE)oid_ops.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \ $(BUILDTOP)/include/gssapi/gssapi.h $(BUILDTOP)/include/gssapi/gssapi_generic.h \ $(COM_ERR_DEPS) $(SRCTOP)/include/k5-platform.h $(SRCTOP)/include/k5-thread.h \ diff --git a/src/lib/gssapi/mechglue/g_indicate_mechs.c b/src/lib/gssapi/mechglue/g_indicate_mechs.c deleted file mode 100644 index e2c8d414fe..0000000000 --- a/src/lib/gssapi/mechglue/g_indicate_mechs.c +++ /dev/null @@ -1,90 +0,0 @@ -/* #ident "@(#)gss_indicate_mechs.c 1.13 95/08/04 SMI" */ - -/* - * Copyright 1996 by Sun Microsystems, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appears in all copies and - * that both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of Sun Microsystems not be used - * in advertising or publicity pertaining to distribution of the software - * without specific, written prior permission. Sun Microsystems makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * glue routine for gss_indicate_mechs - */ - -#include "mglueP.h" -#include -#ifdef HAVE_STDLIB_H -#include -#endif -#include - -extern gss_mechanism *gssint_mechs_array; - -static gss_OID_set_desc supported_mechs_desc; -static gss_OID_set supported_mechs = NULL; - -OM_uint32 KRB5_CALLCONV -gss_indicate_mechs (minor_status, - mech_set) - -OM_uint32 * minor_status; -gss_OID_set * mech_set; - -{ - int i; - - gss_initialize(); - - if (minor_status) - *minor_status = 0; - - /* - * If we have already computed the mechanisms supported, return - * a pointer to it. Otherwise, compute them and return the pointer. - */ - - if(supported_mechs == NULL) { - - supported_mechs = &supported_mechs_desc; - supported_mechs->count = 0; - - /* Build the mech_set from the OIDs in mechs_array. */ - - for(i=0; gssint_mechs_array[i]->mech_type.length != 0; i++) - supported_mechs->count++; - - supported_mechs->elements = - (void *) malloc(supported_mechs->count * - sizeof(gss_OID_desc)); - - for(i=0; i < supported_mechs->count; i++) { - supported_mechs->elements[i].length = - gssint_mechs_array[i]->mech_type.length; - supported_mechs->elements[i].elements = (void *) - malloc(gssint_mechs_array[i]->mech_type.length); - memcpy(supported_mechs->elements[i].elements, - gssint_mechs_array[i]->mech_type.elements, - gssint_mechs_array[i]->mech_type.length); - } - } - - if(mech_set != NULL) - *mech_set = supported_mechs; - - return(GSS_S_COMPLETE); -} diff --git a/src/lib/gssapi/mechglue/g_initialize.c b/src/lib/gssapi/mechglue/g_initialize.c index 2167756275..89134a6cd5 100644 --- a/src/lib/gssapi/mechglue/g_initialize.c +++ b/src/lib/gssapi/mechglue/g_initialize.c @@ -27,6 +27,7 @@ */ #include "mglueP.h" +#include "gss_libinit.h" #ifdef HAVE_STDLIB_H #include #endif @@ -36,29 +37,12 @@ #include #include -#include - -#define MECH_CONF "/etc/gss/mech" - -#define MECH_LIB_PREFIX1 "/usr/lib/" - -#define MECH_LIB_PREFIX2 "" - -#define MECH_LIB_DIR "gss/" - -#define MECH_LIB_PREFIX MECH_LIB_PREFIX1 MECH_LIB_PREFIX2 MECH_LIB_DIR - -#define MECH_SYM "gss_mech_initialize" - #define M_DEFAULT "default" -#include - #include "k5-thread.h" /* Local functions */ static gss_mech_info searchMechList(const gss_OID); -static void loadConfigFile(const char *); static void updateMechList(void); static void register_mech(gss_mechanism, const char *, void *); @@ -72,9 +56,7 @@ static void init_hardcoded(void); static gss_mech_info g_mechList = NULL; static gss_mech_info g_mechListTail = NULL; static k5_mutex_t g_mechListLock = K5_MUTEX_PARTIAL_INITIALIZER; -static time_t g_confFileModTime = (time_t)0; -static time_t g_mechSetTime = (time_t)0; static gss_OID_set_desc g_mechSet = { 0, NULL }; static k5_mutex_t g_mechSetLock = K5_MUTEX_PARTIAL_INITIALIZER; @@ -154,8 +136,6 @@ gss_indicate_mechs(minorStatus, mechSet) OM_uint32 *minorStatus; gss_OID_set *mechSet; { - char *fileName; - struct stat fileInfo; int i, j; gss_OID curItem; @@ -171,18 +151,6 @@ gss_OID_set *mechSet; if (mechSet == NULL) return (GSS_S_CALL_INACCESSIBLE_WRITE); - fileName = MECH_CONF; - -#if 0 - /* - * If we have already computed the mechanisms supported and if it - * is still valid; make a copy and return to caller, - * otherwise build it first. - */ - if ((stat(fileName, &fileInfo) == 0 && - fileInfo.st_mtime > g_mechSetTime)) { - } /* if g_mechSet is out of date or not initialized */ -#endif if (build_mechSet()) return GSS_S_FAILURE; @@ -261,20 +229,6 @@ build_mechSet(void) */ (void) k5_mutex_lock(&g_mechListLock); -#if 0 - /* - * this checks for the case when we need to re-construct the - * g_mechSet structure, but the mechanism list is upto date - * (because it has been read by someone calling - * gssint_get_mechanism) - */ - if (fileInfo.st_mtime > g_confFileModTime) - { - g_confFileModTime = fileInfo.st_mtime; - loadConfigFile(fileName); - } -#endif - updateMechList(); /* @@ -343,9 +297,6 @@ build_mechSet(void) } } -#if 0 - g_mechSetTime = fileInfo.st_mtime; -#endif (void) k5_mutex_unlock(&g_mechSetLock); (void) k5_mutex_unlock(&g_mechListLock); @@ -491,20 +442,9 @@ gssint_get_mechanisms(char *mechArray[], int arrayLen) static void updateMechList(void) { - char *fileName; - struct stat fileInfo; init_hardcoded(); - fileName = MECH_CONF; - -#if 0 - /* check if mechList needs updating */ - if (stat(fileName, &fileInfo) == 0 && - (fileInfo.st_mtime > g_confFileModTime)) { - loadConfigFile(fileName); - g_confFileModTime = fileInfo.st_mtime; - } -#endif + } /* updateMechList */ /* @@ -560,7 +500,6 @@ init_hardcoded(void) extern gss_mechanism *spnego_gss_get_mech_configs(void); gss_mechanism *cflist; static int inited; - gss_mech_info cf; if (inited) return; @@ -589,12 +528,9 @@ init_hardcoded(void) * module if it has not been already loaded. */ gss_mechanism -gssint_get_mechanism(oid) -const gss_OID oid; +gssint_get_mechanism(gss_OID oid) { gss_mech_info aMech; - gss_mechanism (*sym)(const gss_OID); - void *dl; if (gssint_initialize_library()) return NULL; @@ -624,100 +560,11 @@ const gss_OID oid; if (aMech->mech) { (void) k5_mutex_unlock(&g_mechListLock); return (aMech->mech); + } else { + return NULL; } - - /* we found the mechanism, but it is not loaded */ - if ((dl = dlopen(aMech->uLibName, RTLD_NOW)) == NULL) { -#if 0 - (void) syslog(LOG_INFO, "libgss dlopen(%s): %s\n", - aMech->uLibName, dlerror()); -#endif - (void) k5_mutex_unlock(&g_mechListLock); - return ((gss_mechanism)NULL); - } - - if ((sym = (gss_mechanism (*)(const gss_OID))dlsym(dl, MECH_SYM)) - == NULL) { - (void) dlclose(dl); -#if 0 - (void) syslog(LOG_INFO, "unable to initialize mechanism" - " library [%s]\n", aMech->uLibName); -#endif - (void) k5_mutex_unlock(&g_mechListLock); - return ((gss_mechanism)NULL); - } - - /* Call the symbol to get the mechanism table */ - aMech->mech = (*sym)(aMech->mech_type); - - if (aMech->mech == NULL) { - (void) dlclose(dl); -#if 0 - (void) syslog(LOG_INFO, "unable to initialize mechanism" - " library [%s]\n", aMech->uLibName); -#endif - (void) k5_mutex_unlock(&g_mechListLock); - return ((gss_mechanism)NULL); - } - - aMech->dl_handle = dl; - - (void) k5_mutex_unlock(&g_mechListLock); - return (aMech->mech); } /* gssint_get_mechanism */ -gss_mechanism_ext -gssint_get_mechanism_ext(oid) -const gss_OID oid; -{ - gss_mech_info aMech; - gss_mechanism_ext mech_ext; - - /* check if the mechanism is already loaded */ - if ((aMech = searchMechList(oid)) != NULL && aMech->mech_ext != NULL) - return (aMech->mech_ext); - - if (gssint_get_mechanism(oid) == NULL) - return (NULL); - - if (aMech->dl_handle == NULL) - return (NULL); - - /* Load the gss_config_ext struct for this mech */ - - mech_ext = (gss_mechanism_ext)malloc(sizeof (struct gss_config_ext)); - - if (mech_ext == NULL) - return (NULL); - - /* - * dlsym() the mech's 'method' functions for the extended APIs - * - * NOTE: Until the void *context argument is removed from the - * SPI method functions' signatures it will be necessary to have - * different function pointer typedefs and function names for - * the SPI methods than for the API. When this argument is - * removed it will be possible to rename gss_*_sfct to gss_*_fct - * and and gssspi_* to gss_*. - */ - mech_ext->gss_acquire_cred_with_password = - (gss_acquire_cred_with_password_sfct)dlsym(aMech->dl_handle, - "gssspi_acquire_cred_with_password"); - - /* Set aMech->mech_ext */ - (void) k5_mutex_lock(&g_mechListLock); - - if (aMech->mech_ext == NULL) - aMech->mech_ext = mech_ext; - else - free(mech_ext); /* we raced and lost; don't leak */ - - (void) k5_mutex_unlock(&g_mechListLock); - - return (aMech->mech_ext); - -} /* gssint_get_mechanism_ext */ - /* * this routine is used for searching the list of mechanism data. @@ -742,244 +589,3 @@ const gss_OID oid; /* none found */ return ((gss_mech_info) NULL); } /* searchMechList */ - - -/* - * loads the configuration file - * this is called while having a mutex lock on the mechanism list - * entries for libraries that have been loaded can't be modified - * mechNameStr and mech_type fields are not updated during updates - */ -static void loadConfigFile(fileName) -const char *fileName; -{ - char buffer[BUFSIZ], *oidStr, *oid, *sharedLib, *kernMod, *endp; - char *modOptions; - char sharedPath[sizeof (MECH_LIB_PREFIX) + BUFSIZ]; - char *tmpStr; - FILE *confFile; - gss_OID mechOid; - gss_mech_info aMech, tmp; - OM_uint32 minor; - gss_buffer_desc oidBuf; - - if ((confFile = fopen(fileName, "r")) == NULL) { - return; - } - - (void) memset(buffer, 0, sizeof (buffer)); - while (fgets(buffer, BUFSIZ, confFile) != NULL) { - - /* ignore lines beginning with # */ - if (*buffer == '#') - continue; - - /* - * find the first white-space character after - * the mechanism name - */ - oidStr = buffer; - for (oid = buffer; *oid && !isspace(*oid); oid++); - - /* Now find the first non-white-space character */ - if (*oid) { - *oid = '\0'; - oid++; - while (*oid && isspace(*oid)) - oid++; - } - - /* - * If that's all, then this is a corrupt entry. Skip it. - */ - if (! *oid) - continue; - - /* Find the end of the oid and make sure it is NULL-ended */ - for (endp = oid; *endp && !isspace(*endp); endp++) - ; - - if (*endp) { - *endp = '\0'; - } - - /* - * check if an entry for this oid already exists - * if it does, and the library is already loaded then - * we can't modify it, so skip it - */ - oidBuf.value = (void *)oid; - oidBuf.length = strlen(oid); - if (generic_gss_str_to_oid(&minor, &oidBuf, &mechOid) - != GSS_S_COMPLETE) { -#if 0 - (void) syslog(LOG_INFO, "invalid mechanism oid" - " [%s] in configuration file", oid); -#endif - continue; - } - - k5_mutex_lock(&g_mechListLock); - aMech = searchMechList(mechOid); - if (aMech && aMech->mech) { - free(mechOid->elements); - free(mechOid); - k5_mutex_unlock(&g_mechListLock); - continue; - } - k5_mutex_unlock(&g_mechListLock); - - /* Find the start of the shared lib name */ - for (sharedLib = endp+1; *sharedLib && isspace(*sharedLib); - sharedLib++) - ; - - /* - * If that's all, then this is a corrupt entry. Skip it. - */ - if (! *sharedLib) { - free(mechOid->elements); - free(mechOid); - continue; - } - - /* - * Find the end of the shared lib name and make sure it is - * NULL-terminated. - */ - for (endp = sharedLib; *endp && !isspace(*endp); endp++) - ; - - if (*endp) { - *endp = '\0'; - } - - /* Find the start of the optional kernel module lib name */ - for (kernMod = endp+1; *kernMod && isspace(*kernMod); - kernMod++) - ; - - /* - * If this item starts with a bracket "[", then - * it is not a kernel module, but is a list of - * options for the user module to parse later. - */ - if (*kernMod && *kernMod != '[') { - /* - * Find the end of the shared lib name and make sure - * it is NULL-terminated. - */ - for (endp = kernMod; *endp && !isspace(*endp); endp++) - ; - - if (*endp) { - *endp = '\0'; - } - } else - kernMod = NULL; - - /* Find the start of the optional module options list */ - for (modOptions = endp+1; *modOptions && isspace(*modOptions); - modOptions++); - - if (*modOptions == '[') { - /* move past the opening bracket */ - for (modOptions = modOptions+1; - *modOptions && isspace(*modOptions); - modOptions++); - - /* Find the closing bracket */ - for (endp = modOptions; - *endp && *endp != ']'; endp++); - - if (endp) - *endp = '\0'; - - } else { - modOptions = NULL; - } - - (void) strcpy(sharedPath, MECH_LIB_PREFIX); - (void) strcat(sharedPath, sharedLib); - - /* - * are we creating a new mechanism entry or - * just modifying existing (non loaded) mechanism entry - */ - if (aMech) { - /* - * delete any old values and set new - * mechNameStr and mech_type are not modified - */ - if (aMech->kmodName) { - free(aMech->kmodName); - aMech->kmodName = NULL; - } - - if (aMech->optionStr) { - free(aMech->optionStr); - aMech->optionStr = NULL; - } - - if ((tmpStr = strdup(sharedPath)) != NULL) { - if (aMech->uLibName) - free(aMech->uLibName); - aMech->uLibName = tmpStr; - } - - if (kernMod) /* this is an optional parameter */ - aMech->kmodName = strdup(kernMod); - - if (modOptions) /* optional module options */ - aMech->optionStr = strdup(modOptions); - - /* the oid is already set */ - free(mechOid->elements); - free(mechOid); - continue; - } - - /* adding a new entry */ - aMech = malloc(sizeof (struct gss_mech_config)); - if (aMech == NULL) { - free(mechOid->elements); - free(mechOid); - continue; - } - (void) memset(aMech, 0, sizeof (struct gss_mech_config)); - aMech->mech_type = mechOid; - aMech->uLibName = strdup(sharedPath); - aMech->mechNameStr = strdup(oidStr); - - /* check if any memory allocations failed - bad news */ - if (aMech->uLibName == NULL || aMech->mechNameStr == NULL) { - if (aMech->uLibName) - free(aMech->uLibName); - if (aMech->mechNameStr) - free(aMech->mechNameStr); - free(mechOid->elements); - free(mechOid); - free(aMech); - continue; - } - if (kernMod) /* this is an optional parameter */ - aMech->kmodName = strdup(kernMod); - - if (modOptions) - aMech->optionStr = strdup(modOptions); - /* - * add the new entry to the end of the list - make sure - * that only complete entries are added because other - * threads might currently be searching the list. - */ - tmp = g_mechListTail; - g_mechListTail = aMech; - - if (tmp != NULL) - tmp->next = aMech; - - if (g_mechList == NULL) - g_mechList = aMech; - } /* while */ - (void) fclose(confFile); -} /* loadConfigFile */ diff --git a/src/lib/gssapi/mechglue/g_userok.c b/src/lib/gssapi/mechglue/g_userok.c deleted file mode 100644 index 4657b8eb1d..0000000000 --- a/src/lib/gssapi/mechglue/g_userok.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* #pragma ident "@(#)g_userok.c 1.1 04/03/25 SMI" */ - -#include -#include -#include -#include -#include - - -static OM_uint32 -compare_names(OM_uint32 *minor, - const gss_OID mech_type, - const gss_name_t name, - const char *user, - int *user_ok) -{ - - OM_uint32 status, tmpMinor; - gss_name_t imported_name; - gss_name_t canon_name; - gss_buffer_desc gss_user; - int match = 0; - - *user_ok = 0; - - gss_user.value = (void *)user; - if (!gss_user.value || !name || !mech_type) - return (GSS_S_BAD_NAME); - gss_user.length = strlen(gss_user.value); - - status = gss_import_name(minor, - &gss_user, - GSS_C_NT_USER_NAME, - &imported_name); - if (status != GSS_S_COMPLETE) { - goto out; - } - - status = gss_canonicalize_name(minor, - imported_name, - mech_type, - &canon_name); - if (status != GSS_S_COMPLETE) { - (void) gss_release_name(&tmpMinor, &imported_name); - goto out; - } - - status = gss_compare_name(minor, - canon_name, - name, - &match); - (void) gss_release_name(&tmpMinor, &canon_name); - (void) gss_release_name(&tmpMinor, &imported_name); - if (status == GSS_S_COMPLETE) { - if (match) - *user_ok = 1; /* remote user is a-ok */ - } - -out: - return (status); -} - - -OM_uint32 -gssint_userok(OM_uint32 *minor, - const gss_name_t name, - const char *user, - int *user_ok) - -{ - gss_mechanism mech; - gss_union_name_t intName; - gss_name_t mechName = NULL; - OM_uint32 major; - - if (minor == NULL || user_ok == NULL) - return (GSS_S_CALL_INACCESSIBLE_WRITE); - - if (name == NULL || user == NULL) - return (GSS_S_CALL_INACCESSIBLE_READ); - - *user_ok = 0; - *minor = GSS_S_COMPLETE; - - intName = (gss_union_name_t)name; - - mech = gssint_get_mechanism(intName->mech_type); - if (mech == NULL) - return (GSS_S_UNAVAILABLE); - - /* may need to import the name if this is not MN */ - if (intName->mech_type == NULL) { - return (GSS_S_FAILURE); - } else - mechName = intName->mech_name; - - if (mech->gssint_userok) - major = mech->gssint_userok(mech->context, minor, mechName, - user, user_ok); - else - major = compare_names(minor, intName->mech_type, - name, user, user_ok); - - return (major); -} /* gss_userok */ diff --git a/src/lib/gssapi/mechglue/g_utils.c b/src/lib/gssapi/mechglue/g_utils.c deleted file mode 100644 index 82fe70d95b..0000000000 --- a/src/lib/gssapi/mechglue/g_utils.c +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright 2004 Sun Microsystems, Inc. All rights reserved. - * Use is subject to license terms. - */ - -/* #pragma ident "@(#)g_utils.c 1.8 04/02/23 SMI" */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#define Q_DEFAULT "default" -#define BUFLEN 256 - -#if 0 -static int qop_num_pair_cnt; -static const char QOP_NUM_FILE[] = "/etc/gss/qop"; -static qop_num qop_num_pairs[MAX_QOP_NUM_PAIRS+1]; -static mutex_t qopfile_lock = DEFAULTMUTEX; - -static OM_uint32 gssint_read_qop_file(void); - -/* - * This routine fetches qop and num from "/etc/gss/qop". - * There is a memory leak associated with rereading this file, - * because we can't free the qop_num_pairs array when we reread - * the file (some callers may have been given these pointers). - * In general, this memory leak should be a small one, because - * we don't expect the qop file to be changed and reread often. - */ -static OM_uint32 -gssint_read_qop_file(void) -{ - char buf[BUFLEN]; /* one line from the file */ - char *name, *next; - char *qopname, *num_str; - char *line; - FILE *fp; - static int last = 0; - struct stat stbuf; - OM_uint32 major = GSS_S_COMPLETE; - - (void) mutex_lock(&qopfile_lock); - if (stat(QOP_NUM_FILE, &stbuf) != 0 || stbuf.st_mtime < last) { - if (!qop_num_pairs[0].qop) { - major = GSS_S_FAILURE; - } - goto done; - } - last = stbuf.st_mtime; - - fp = fopen(QOP_NUM_FILE, "r"); - if (fp == (FILE *)0) { - major = GSS_S_FAILURE; - goto done; - } - - /* - * For each line in the file parse it appropriately. - * File format : qopname num(int) - * Note that we silently ignore corrupt entries. - */ - qop_num_pair_cnt = 0; - while (!feof(fp)) { - line = fgets(buf, BUFLEN, fp); - if (line == NULL) - break; - - /* Skip comments and blank lines */ - if ((*line == '#') || (*line == '\n')) - continue; - - /* Skip trailing comments */ - next = strchr(line, '#'); - if (next) - *next = '\0'; - - name = &(buf[0]); - while (isspace(*name)) - name++; - if (*name == '\0') /* blank line */ - continue; - - qopname = name; /* will contain qop name */ - while (!isspace(*qopname)) - qopname++; - if (*qopname == '\0') { - continue; - } - next = qopname+1; - *qopname = '\0'; /* null terminate qopname */ - qop_num_pairs[qop_num_pair_cnt].qop = strdup(name); - if (qop_num_pairs[qop_num_pair_cnt].qop == NULL) - continue; - - name = next; - while (isspace(*name)) - name++; - if (*name == '\0') { /* end of line, no num */ - free(qop_num_pairs[qop_num_pair_cnt].qop); - continue; - } - num_str = name; /* will contain num (n) */ - while (!isspace(*num_str)) - num_str++; - next = num_str+1; - *num_str++ = '\0'; /* null terminate num_str */ - - qop_num_pairs[qop_num_pair_cnt].num = (OM_uint32)atoi(name); - name = next; - while (isspace(*name)) - name++; - if (*name == '\0') { /* end of line, no mechanism */ - free(qop_num_pairs[qop_num_pair_cnt].qop); - continue; - } - num_str = name; /* will contain mech */ - while (!isspace(*num_str)) - num_str++; - *num_str = '\0'; - - qop_num_pairs[qop_num_pair_cnt].mech = strdup(name); - if (qop_num_pairs[qop_num_pair_cnt].mech == NULL) { - free(qop_num_pairs[qop_num_pair_cnt].qop); - continue; - } - - if (qop_num_pair_cnt++ >= MAX_QOP_NUM_PAIRS) - break; - } - (void) fclose(fp); -done: - (void) mutex_unlock(&qopfile_lock); - return (major); -} - -OM_uint32 -gssint_qop_to_num( - char *qop, - char *mech, - OM_uint32 *num -) -{ - int i; - OM_uint32 major = GSS_S_FAILURE; - - if (!num) - return (GSS_S_CALL_INACCESSIBLE_WRITE); - - if (qop == NULL || strlen(qop) == 0 || - strcasecmp(qop, Q_DEFAULT) == 0) { - *num = GSS_C_QOP_DEFAULT; - return (GSS_S_COMPLETE); - } - - if ((major = gssint_read_qop_file()) != GSS_S_COMPLETE) - return (major); - - for (i = 0; i < qop_num_pair_cnt; i++) { - if ((strcasecmp(mech, qop_num_pairs[i].mech) == 0) && - (strcasecmp(qop, qop_num_pairs[i].qop) == 0)) { - *num = qop_num_pairs[i].num; - return (GSS_S_COMPLETE); - } - } - - return (GSS_S_FAILURE); -} - -OM_uint32 -gssint_num_to_qop( - char *mech, - OM_uint32 num, - char **qop -) -{ - int i; - OM_uint32 major; - - if (!qop) - return (GSS_S_CALL_INACCESSIBLE_WRITE); - *qop = NULL; - - if (num == GSS_C_QOP_DEFAULT) { - *qop = Q_DEFAULT; - return (GSS_S_COMPLETE); - } - - if (mech == NULL) - return (GSS_S_CALL_INACCESSIBLE_READ); - - if ((major = gssint_read_qop_file()) != GSS_S_COMPLETE) - return (major); - - for (i = 0; i < qop_num_pair_cnt; i++) { - if ((strcasecmp(mech, qop_num_pairs[i].mech) == 0) && - (num == qop_num_pairs[i].num)) { - *qop = qop_num_pairs[i].qop; - return (GSS_S_COMPLETE); - } - } - return (GSS_S_FAILURE); -} - -/* - * For a given mechanism pass back qop information about it in a buffer - * of size MAX_QOPS_PER_MECH+1. - */ -OM_uint32 -gssint_get_mech_info( - char *mech, - char **qops -) -{ - int i, cnt = 0; - OM_uint32 major = GSS_S_COMPLETE; - - if (!qops) - return (GSS_S_CALL_INACCESSIBLE_WRITE); - *qops = NULL; - - if (!mech) - return (GSS_S_CALL_INACCESSIBLE_READ); - - if ((major = gssint_read_qop_file()) != GSS_S_COMPLETE) - return (major); - - for (i = 0; i < qop_num_pair_cnt; i++) { - if (strcmp(mech, qop_num_pairs[i].mech) == 0) { - if (cnt >= MAX_QOPS_PER_MECH) { - return (GSS_S_FAILURE); - } - qops[cnt++] = qop_num_pairs[i].qop; - } - } - qops[cnt] = NULL; - return (GSS_S_COMPLETE); -} - -/* - * Copy the qop values and names for the mechanism back in a qop_num - * buffer of size MAX_QOPS_PER_MECH provided by the caller. - */ -OM_uint32 -gssint_mech_qops( - char *mech, - qop_num *mechqops, - int *numqop -) -{ - int i; - OM_uint32 major; - int cnt = 0; - - if (!mechqops || !numqop) - return (GSS_S_CALL_INACCESSIBLE_WRITE); - *numqop = 0; - - if (!mech) - return (GSS_S_CALL_INACCESSIBLE_READ); - - if ((major = gssint_read_qop_file()) != GSS_S_COMPLETE) - return (major); - - for (i = 0; i < qop_num_pair_cnt; i++) { - if (strcasecmp(mech, qop_num_pairs[i].mech) == 0) { - if (cnt >= MAX_QOPS_PER_MECH) { - return (GSS_S_FAILURE); - } - mechqops[cnt++] = qop_num_pairs[i]; - } - } - *numqop = cnt; - return (GSS_S_COMPLETE); -} -#endif diff --git a/src/lib/gssapi/mechglue/gen_oids.c b/src/lib/gssapi/mechglue/gen_oids.c deleted file mode 100644 index cd3c1a8350..0000000000 --- a/src/lib/gssapi/mechglue/gen_oids.c +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 1993 by OpenVision Technologies, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appears in all copies and - * that both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of OpenVision not be used - * in advertising or publicity pertaining to distribution of the software - * without specific, written prior permission. OpenVision makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include "mglueP.h" - -/* - * See krb5/gssapi_krb5.c for a description of the algorithm for - * encoding an object identifier. - */ - -/* - * The OID of user_name is: - * iso(1) member-body(2) US(840) mit(113554) infosys(1) gssapi(2) - * generic(1) user_name(1) = 1.2.840.113554.1.2.1.1 - * machine_uid_name: - * iso(1) member-body(2) US(840) mit(113554) infosys(1) gssapi(2) - * generic(1) machine_uid_name(2) = 1.2.840.113554.1.2.1.2 - * string_uid_name: - * iso(1) member-body(2) US(840) mit(113554) infosys(1) gssapi(2) - * generic(1) string_uid_name(3) = 1.2.840.113554.1.2.1.3 - * service_name: - * iso(1) member-body(2) US(840) mit(113554) infosys(1) gssapi(2) - * generic(1) service_name(4) = 1.2.840.113554.1.2.1.4 - */ - -static const gss_OID_desc oids[] = { - {10, "\052\206\110\206\367\022\001\002\001\001"}, - {10, "\052\206\110\206\367\022\001\002\001\002"}, - {10, "\052\206\110\206\367\022\001\002\001\003"}, - {10, "\052\206\110\206\367\022\001\002\001\004"}, -}; - -const gss_OID_desc * const gss_nt_user_name = oids+0; -const gss_OID_desc * const gss_nt_machine_uid_name = oids+1; -const gss_OID_desc * const gss_nt_string_uid_name = oids+2; -const gss_OID_desc * const gss_nt_service_name = oids+3; diff --git a/src/lib/gssapi/mechglue/gssd_pname_to_uid.c b/src/lib/gssapi/mechglue/gssd_pname_to_uid.c deleted file mode 100644 index f15b16c5db..0000000000 --- a/src/lib/gssapi/mechglue/gssd_pname_to_uid.c +++ /dev/null @@ -1,65 +0,0 @@ -/* #pragma ident "@(#)gssd_pname_to_uid.c 1.18 04/02/23 SMI" */ - -/* - * Copyright 1996 by Sun Microsystems, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software - * and its documentation for any purpose is hereby granted without fee, - * provided that the above copyright notice appears in all copies and - * that both that copyright notice and this permission notice appear in - * supporting documentation, and that the name of Sun Microsystems not be used - * in advertising or publicity pertaining to distribution of the software - * without specific, written prior permission. Sun Microsystems makes no - * representations about the suitability of this software for any - * purpose. It is provided "as is" without express or implied warranty. - * - * SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO - * EVENT SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF - * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR - * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * glue routines that test the mech id either passed in to - * gss_init_sec_contex() or gss_accept_sec_context() or within the glue - * routine supported version of the security context and then call - * the appropriate underlying mechanism library procedure. - * - */ - -#include "mglueP.h" - -int gssd_pname_to_uid(pname, name_type, mech_type, uid) - -char * pname; -gss_OID name_type; -gss_OID mech_type; -uid_t * uid; -{ - int status; - gss_mechanism mech; - - /* - * find the appropriate mechanism specific pname_to_uid procedure and - * call it. - */ - - mech = gssint_get_mechanism (mech_type); - - if (mech) { - if (mech_type == GSS_C_NULL_OID) - mech_type = &mech->mech_type; - - if (mech->pname_to_uid) - status = mech->pname_to_uid(mech->context, - pname, name_type, mech_type, uid); - else - status = GSS_S_BAD_MECH; - } else - status = GSS_S_BAD_MECH; - - return(status); -} diff --git a/src/lib/gssapi/mechglue/mechglue.h b/src/lib/gssapi/mechglue/mechglue.h index 691b30a96c..4f4cd481cb 100644 --- a/src/lib/gssapi/mechglue/mechglue.h +++ b/src/lib/gssapi/mechglue/mechglue.h @@ -35,7 +35,4 @@ /* GSSAPI Extension functions -- these functions aren't */ /* in the GSSAPI, but they are provided in this library */ -int gssd_pname_to_uid (char *, gss_OID, gss_OID, uid_t *); -void gss_initialize (void); - #endif /* _GSS_MECHGLUE_H */ diff --git a/src/lib/gssapi/mechglue/mglueP.h b/src/lib/gssapi/mechglue/mglueP.h index bfee2524a8..2becac9608 100644 --- a/src/lib/gssapi/mechglue/mglueP.h +++ b/src/lib/gssapi/mechglue/mglueP.h @@ -76,19 +76,6 @@ typedef struct gss_union_cred_t { gss_union_cred_auxinfo auxinfo; } gss_union_cred_desc, *gss_union_cred_t; -typedef OM_uint32 (*gss_acquire_cred_with_password_sfct)( - void *, /* context */ - OM_uint32 *, /* minor_status */ - const gss_name_t, /* desired_name */ - const gss_buffer_t, /* password */ - OM_uint32, /* time_req */ - const gss_OID_set, /* desired_mechs */ - int, /* cred_usage */ - gss_cred_id_t *, /* output_cred_handle */ - gss_OID_set *, /* actual_mechs */ - OM_uint32 * /* time_rec */ - /* */); - /********************************************************/ /* The Mechanism Dispatch Table -- a mechanism needs to */ /* define one of these and provide a function to return */ @@ -352,22 +339,6 @@ typedef struct gss_config { OM_uint32, /* req_output_size */ OM_uint32 * /* max_input_size */ ); - int (*pname_to_uid) - ( - void *, /* context */ - char *, /* pname */ - gss_OID, /* name type */ - gss_OID, /* mech type */ - uid_t * /* uid */ - ); - OM_uint32 (*gssint_userok) - ( - void *, /* context */ - OM_uint32 *, /* minor_status */ - const gss_name_t, /* pname */ - const char *, /* local user */ - int * /* user ok? */ - /* */); OM_uint32 (*gss_export_name) ( void *, /* context */ @@ -389,11 +360,6 @@ typedef struct gss_config { /* */); } *gss_mechanism; -/* This structure MUST NOT be used by any code outside libgss */ -typedef struct gss_config_ext { - gss_acquire_cred_with_password_sfct gss_acquire_cred_with_password; -} *gss_mechanism_ext; - /* * In the user space we use a wrapper structure to encompass the * mechanism entry points. The wrapper contain the mechanism @@ -409,7 +375,6 @@ typedef struct gss_mech_config { void *dl_handle; /* RTLD object handle for the mech */ gss_OID mech_type; /* mechanism oid */ gss_mechanism mech; /* mechanism initialization struct */ - gss_mechanism_ext mech_ext; /* extensions */ struct gss_mech_config *next; /* next element in the list */ } *gss_mech_info; @@ -420,7 +385,6 @@ int gssint_mechglue_init(void); void gssint_mechglue_fini(void); gss_mechanism gssint_get_mechanism (gss_OID); -gss_mechanism_ext gssint_get_mechanism_ext(const gss_OID); OM_uint32 gssint_get_mech_type (gss_OID, gss_buffer_t); char *gssint_get_kmodName(const gss_OID); char *gssint_get_modOptions(const gss_OID); @@ -484,14 +448,6 @@ gssint_get_mechanisms( int arrayLen /* length of passed in array */ ); -OM_uint32 -gssint_userok( - OM_uint32 *, /* minor */ - const gss_name_t, /* name */ - const char *, /* user */ - int * /* user_ok */ -); - OM_uint32 gss_store_cred( OM_uint32 *, /* minor_status */ diff --git a/src/lib/gssapi/spnego/Makefile.in b/src/lib/gssapi/spnego/Makefile.in index ba6fe9ad0a..11b91aae95 100644 --- a/src/lib/gssapi/spnego/Makefile.in +++ b/src/lib/gssapi/spnego/Makefile.in @@ -18,9 +18,11 @@ STLIBOBJS = spnego_mech.o all-unix:: all-libobjs +##DOS##LIBOBJS = $(OBJS) + clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # # Makefile dependencies follow. This must be the last section in @@ -28,8 +30,12 @@ clean-unix:: clean-libobjs # spnego_mech.so spnego_mech.po $(OUTPRE)spnego_mech.$(OBJEXT): \ $(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/gssapi/gssapi.h \ - $(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) $(SRCTOP)/include/k5-platform.h \ - $(SRCTOP)/include/k5-thread.h $(SRCTOP)/include/krb5.h \ + $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \ + $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(SRCTOP)/include/k5-err.h \ + $(SRCTOP)/include/k5-int.h $(SRCTOP)/include/k5-platform.h \ + $(SRCTOP)/include/k5-plugin.h $(SRCTOP)/include/k5-thread.h \ + $(SRCTOP)/include/krb5.h $(SRCTOP)/include/krb5/locate_plugin.h \ + $(SRCTOP)/include/port-sockets.h $(SRCTOP)/include/socket-utils.h \ $(SRCTOP)/include/syslog.h $(srcdir)/../generic/gssapiP_generic.h \ $(srcdir)/../generic/gssapi_generic.h $(srcdir)/../mechglue/mechglue.h \ $(srcdir)/../mechglue/mglueP.h ../generic/gssapi_err_generic.h \ diff --git a/src/lib/gssapi/spnego/gssapiP_spnego.h b/src/lib/gssapi/spnego/gssapiP_spnego.h index 2d3e5e20b3..1c8fd7a7b5 100644 --- a/src/lib/gssapi/spnego/gssapiP_spnego.h +++ b/src/lib/gssapi/spnego/gssapiP_spnego.h @@ -117,10 +117,6 @@ static const gss_OID_set_desc spnego_oidsets[] = { }; const gss_OID_set_desc * const gss_mech_set_spnego = spnego_oidsets+0; -#define TWRITE_STR(ptr, str, len) \ - memcpy((ptr), (char *)(str), (len)); \ - (ptr) += (len); - #ifdef DEBUG #define dsyslog(a) syslog(LOG_DEBUG, a) #else diff --git a/src/lib/gssapi/spnego/spnego_mech.c b/src/lib/gssapi/spnego/spnego_mech.c index ec8b6083a9..0db0b5f92b 100644 --- a/src/lib/gssapi/spnego/spnego_mech.c +++ b/src/lib/gssapi/spnego/spnego_mech.c @@ -39,9 +39,10 @@ #include #include #include +#include #include -#include "gssapiP_spnego.h" #include +#include "gssapiP_spnego.h" #include #undef g_token_size @@ -61,24 +62,26 @@ extern int gssint_put_der_length(OM_uint32, unsigned char **, OM_uint32); static spnego_token_t make_spnego_token(char *); static gss_buffer_desc make_err_msg(char *); static int g_token_size(gss_OID_const, OM_uint32); -static int g_make_token_header(gss_OID_const, int, unsigned char **, int); -static int g_verify_token_header(gss_OID_const, int *, unsigned char **, - int, int); -static int g_verify_neg_token_init(unsigned char **, int); +static int g_make_token_header(gss_OID_const, unsigned int, + unsigned char **, unsigned int); +static int g_verify_token_header(gss_OID_const, unsigned int *, + unsigned char **, + int, unsigned int); +static int g_verify_neg_token_init(unsigned char **, unsigned int); static gss_OID get_mech_oid(OM_uint32 *, unsigned char **, size_t); -static gss_buffer_t get_input_token(unsigned char **, int); -static gss_OID_set get_mech_set(OM_uint32 *, unsigned char **, int); +static gss_buffer_t get_input_token(unsigned char **, unsigned int); +static gss_OID_set get_mech_set(OM_uint32 *, unsigned char **, unsigned int); static OM_uint32 get_req_flags(unsigned char **, OM_uint32, OM_uint32 *); static OM_uint32 get_available_mechs(OM_uint32 *, gss_name_t, gss_cred_usage_t, gss_cred_id_t *, gss_OID_set *); static void release_spnego_ctx(spnego_gss_ctx_id_t *); static void check_spnego_options(spnego_gss_ctx_id_t); static spnego_gss_ctx_id_t create_spnego_ctx(void); -static int put_req_flags(unsigned char **, OM_uint32, int); +static int put_req_flags(unsigned char **, OM_uint32, unsigned int); static int put_mech_set(gss_OID_set mechSet, gss_buffer_t buf); -static int put_input_token(unsigned char **, gss_buffer_t, int); -static int put_mech_oid(unsigned char **, gss_OID_const, int); -static int put_negResult(unsigned char **, OM_uint32, int); +static int put_input_token(unsigned char **, gss_buffer_t, unsigned int); +static int put_mech_oid(unsigned char **, gss_OID_const, unsigned int); +static int put_negResult(unsigned char **, OM_uint32, unsigned int); static OM_uint32 process_mic(OM_uint32 *, gss_buffer_t, spnego_gss_ctx_id_t, @@ -129,7 +132,7 @@ static gss_OID negotiate_mech_type(OM_uint32 *, gss_OID_set, gss_OID_set, OM_uint32 *); static int -g_get_tag_and_length(unsigned char **, int, int, int *); +g_get_tag_and_length(unsigned char **, int, unsigned int, unsigned int *); static int make_spnego_tokenInit_msg(spnego_gss_ctx_id_t, gss_buffer_t, @@ -184,8 +187,6 @@ static struct gss_config spnego_mechanism = spnego_gss_inquire_context, /* gss_inquire_context */ NULL, /* gss_internal_release_oid */ spnego_gss_wrap_size_limit, /* gss_wrap_size_limit */ - NULL, /* gss_pname_to_uid */ - NULL, /* gssint_userok */ NULL, /* gss_export_name */ NULL, /* gss_store_cred */ }; @@ -976,7 +977,7 @@ acc_ctx_cont(OM_uint32 *minstat, OM_uint32 ret, tmpmin; gss_OID supportedMech; spnego_gss_ctx_id_t sc; - int len; + unsigned int len; unsigned char *ptr, *bufstart; sc = (spnego_gss_ctx_id_t)*ctx; @@ -1779,7 +1780,7 @@ get_mech_oid(OM_uint32 *minor_status, unsigned char **buff_in, size_t length) */ static int -put_mech_oid(unsigned char **buf_out, gss_OID_const mech, int buflen) +put_mech_oid(unsigned char **buf_out, gss_OID_const mech, unsigned int buflen) { if (buflen < mech->length + 2) return (-1); @@ -1797,7 +1798,7 @@ put_mech_oid(unsigned char **buf_out, gss_OID_const mech, int buflen) * buffer pointer. */ static gss_buffer_t -get_input_token(unsigned char **buff_in, int buff_length) +get_input_token(unsigned char **buff_in, unsigned int buff_length) { gss_buffer_t input_token; unsigned int bytes; @@ -1836,7 +1837,7 @@ get_input_token(unsigned char **buff_in, int buff_length) static int put_input_token(unsigned char **buf_out, gss_buffer_t input_token, - int buflen) + unsigned int buflen) { int ret; @@ -1851,7 +1852,7 @@ put_input_token(unsigned char **buf_out, gss_buffer_t input_token, if ((ret = gssint_put_der_length(input_token->length, buf_out, input_token->length))) return (ret); - TWRITE_STR(*buf_out, input_token->value, ((int)input_token->length)); + TWRITE_STR(*buf_out, input_token->value, input_token->length); return (0); } @@ -1862,7 +1863,8 @@ put_input_token(unsigned char **buf_out, gss_buffer_t input_token, * return it, advancing the buffer pointer. */ static gss_OID_set -get_mech_set(OM_uint32 *minor_status, unsigned char **buff_in, int buff_length) +get_mech_set(OM_uint32 *minor_status, unsigned char **buff_in, + unsigned int buff_length) { gss_OID_set returned_mechSet; OM_uint32 major_status; @@ -1908,7 +1910,8 @@ static int put_mech_set(gss_OID_set mechSet, gss_buffer_t buf) { unsigned char *ptr; - int i, tlen, ilen; + int i; + unsigned int tlen, ilen; tlen = ilen = 0; for (i = 0; i < mechSet->count; i++) { @@ -1952,8 +1955,7 @@ static OM_uint32 get_req_flags(unsigned char **buff_in, OM_uint32 bodysize, OM_uint32 *req_flags) { - int len; - unsigned char *start = *buff_in; + unsigned int len; if (**buff_in != (CONTEXT | 0x01)) return (0); @@ -1981,7 +1983,8 @@ get_req_flags(unsigned char **buff_in, OM_uint32 bodysize, */ static int -put_req_flags(unsigned char **buf_out, OM_uint32 req_flags, int buflen) +put_req_flags(unsigned char **buf_out, OM_uint32 req_flags, + unsigned int buflen) { int ret = 0; if (buflen < 6) @@ -2009,7 +2012,7 @@ get_negTokenInit(OM_uint32 *minor_status, { OM_uint32 err; unsigned char *ptr, *bufstart; - int len; + unsigned int len; gss_buffer_desc tmpbuf; *minor_status = 0; @@ -2022,7 +2025,7 @@ get_negTokenInit(OM_uint32 *minor_status, ptr = bufstart = buf->value; if ((buf->length - (ptr - bufstart)) > INT_MAX) return GSS_S_FAILURE; -#define REMAIN ((int)(buf->length - (ptr - bufstart))) +#define REMAIN (buf->length - (ptr - bufstart)) err = g_verify_token_header(gss_mech_spnego, &len, &ptr, 0, REMAIN); @@ -2079,8 +2082,9 @@ get_negTokenResp(OM_uint32 *minor_status, gss_buffer_t *mechListMIC) { unsigned char *ptr, *bufstart; - int len, bytes; - unsigned int tag; + unsigned int len; + int tmplen; + unsigned int tag, bytes; *negState = ACCEPT_DEFECTIVE_TOKEN; *supportedMech = GSS_C_NO_OID; @@ -2091,8 +2095,8 @@ get_negTokenResp(OM_uint32 *minor_status, if (g_get_tag_and_length(&ptr, (CONTEXT | 0x01), REMAIN, &len) < 0) return GSS_S_DEFECTIVE_TOKEN; if (*ptr++ == SEQUENCE) { - len = gssint_get_der_length(&ptr, REMAIN, &bytes); - if (len < 0) + tmplen = gssint_get_der_length(&ptr, REMAIN, &bytes); + if (tmplen < 0) return GSS_S_DEFECTIVE_TOKEN; } if (REMAIN < 1) @@ -2101,8 +2105,8 @@ get_negTokenResp(OM_uint32 *minor_status, tag = *ptr++; if (tag == CONTEXT) { - len = gssint_get_der_length(&ptr, REMAIN, &bytes); - if (len < 0) + tmplen = gssint_get_der_length(&ptr, REMAIN, &bytes); + if (tmplen < 0) return GSS_S_DEFECTIVE_TOKEN; if (g_get_tag_and_length(&ptr, ENUMERATED, @@ -2122,8 +2126,8 @@ get_negTokenResp(OM_uint32 *minor_status, tag = *ptr++; } if (tag == (CONTEXT | 0x01)) { - len = gssint_get_der_length(&ptr, REMAIN, &bytes); - if (len < 0) + tmplen = gssint_get_der_length(&ptr, REMAIN, &bytes); + if (tmplen < 0) return GSS_S_DEFECTIVE_TOKEN; *supportedMech = get_mech_oid(minor_status, &ptr, REMAIN); @@ -2136,8 +2140,8 @@ get_negTokenResp(OM_uint32 *minor_status, tag = *ptr++; } if (tag == (CONTEXT | 0x02)) { - len = gssint_get_der_length(&ptr, REMAIN, &bytes); - if (len < 0) + tmplen = gssint_get_der_length(&ptr, REMAIN, &bytes); + if (tmplen < 0) return GSS_S_DEFECTIVE_TOKEN; *responseToken = get_input_token(&ptr, REMAIN); @@ -2150,8 +2154,8 @@ get_negTokenResp(OM_uint32 *minor_status, tag = *ptr++; } if (tag == (CONTEXT | 0x03)) { - len = gssint_get_der_length(&ptr, REMAIN, &bytes); - if (len < 0) + tmplen = gssint_get_der_length(&ptr, REMAIN, &bytes); + if (tmplen < 0) return GSS_S_DEFECTIVE_TOKEN; *mechListMIC = get_input_token(&ptr, REMAIN); @@ -2168,7 +2172,8 @@ get_negTokenResp(OM_uint32 *minor_status, */ static int -put_negResult(unsigned char **buf_out, OM_uint32 negResult, int buflen) +put_negResult(unsigned char **buf_out, OM_uint32 negResult, + unsigned int buflen) { if (buflen < 3) return (-1); @@ -2273,18 +2278,16 @@ make_spnego_tokenInit_msg(spnego_gss_ctx_id_t spnego_ctx, gss_buffer_t data, send_token_flag sendtoken, gss_buffer_t outbuf) { - int tlen, dataLen = 0, ret = 0; - int negTokenInitSize = 0; - int negTokenInitSeqSize = 0; - int negTokenInitContSize = 0; - int rspTokenSize = 0; - int mechListTokenSize = 0; - int micTokenSize = 0; - int i; + int ret = 0; + unsigned int tlen, dataLen = 0; + unsigned int negTokenInitSize = 0; + unsigned int negTokenInitSeqSize = 0; + unsigned int negTokenInitContSize = 0; + unsigned int rspTokenSize = 0; + unsigned int mechListTokenSize = 0; + unsigned int micTokenSize = 0; unsigned char *t; unsigned char *ptr; - unsigned char *MechListPtr = NULL; - gss_buffer_desc MICbuff; if (outbuf == GSS_C_NO_BUFFER) return (-1); @@ -2448,14 +2451,13 @@ make_spnego_tokenTarg_msg(OM_uint32 status, gss_OID mech_wanted, send_token_flag sendtoken, gss_buffer_t outbuf) { - int tlen; - int ret; - int NegTokenTargSize; - int negresultTokenSize; - int NegTokenSize; - int rspTokenSize; - int micTokenSize; - int dataLen = 0; + unsigned int tlen = 0; + unsigned int ret = 0; + unsigned int NegTokenTargSize = 0; + unsigned int NegTokenSize = 0; + unsigned int rspTokenSize = 0; + unsigned int micTokenSize = 0; + unsigned int dataLen = 0; unsigned char *t; unsigned char *ptr; @@ -2668,11 +2670,12 @@ g_token_size(gss_OID_const mech, unsigned int body_size) */ static int g_make_token_header(gss_OID_const mech, - int body_size, + unsigned int body_size, unsigned char **buf, - int totallen) + unsigned int totallen) { - int hdrsize, ret = 0; + int ret = 0; + unsigned int hdrsize; unsigned char *p = *buf; hdrsize = 1 + gssint_der_length_size(mech->length) + mech->length; @@ -2685,7 +2688,7 @@ g_make_token_header(gss_OID_const mech, if ((ret = gssint_put_der_length(mech->length, buf, totallen - (int)(p - *buf)))) return (ret); - TWRITE_STR(*buf, mech->elements, ((int)mech->length)); + TWRITE_STR(*buf, mech->elements, mech->length); return (0); } @@ -2696,34 +2699,37 @@ g_make_token_header(gss_OID_const mech, * theory. */ static int -g_get_tag_and_length(unsigned char **buf, int tag, int buflen, int *outlen) +g_get_tag_and_length(unsigned char **buf, int tag, + unsigned int buflen, unsigned int *outlen) { unsigned char *ptr = *buf; int ret = -1; /* pessimists, assume failure ! */ unsigned int encoded_len; + int tmplen = 0; + *outlen = 0; if (buflen > 1 && *ptr == tag) { ptr++; - *outlen = gssint_get_der_length(&ptr, buflen - 1, + tmplen = gssint_get_der_length(&ptr, buflen - 1, &encoded_len); - if (*outlen < 0) { + if (tmplen < 0) { ret = -1; - } else if (*outlen > buflen - (ptr - *buf)) { + } else if (tmplen > buflen - (ptr - *buf)) { ret = -1; } else ret = 0; } - + *outlen = tmplen; *buf = ptr; return (ret); } static int -g_verify_neg_token_init(unsigned char **buf_in, int cur_size) +g_verify_neg_token_init(unsigned char **buf_in, unsigned int cur_size) { unsigned char *buf = *buf_in; unsigned char *endptr = buf + cur_size; - int seqsize; + unsigned int seqsize; int ret = 0; unsigned int bytes; @@ -2783,10 +2789,10 @@ g_verify_neg_token_init(unsigned char **buf_in, int cur_size) /* verify token header. */ static int g_verify_token_header(gss_OID_const mech, - int *body_size, + unsigned int *body_size, unsigned char **buf_in, int tok_type, - int toksize) + unsigned int toksize) { unsigned char *buf = *buf_in; int seqsize; @@ -2794,7 +2800,7 @@ g_verify_token_header(gss_OID_const mech, int ret = 0; unsigned int bytes; - if ((toksize -= 1) < 0) + if (toksize-- < 1) return (G_BAD_TOK_HEADER); if (*buf++ != HEADER_ID) @@ -2806,20 +2812,22 @@ g_verify_token_header(gss_OID_const mech, if ((seqsize + bytes) != toksize) return (G_BAD_TOK_HEADER); - if ((toksize -= 1) < 0) + if (toksize-- < 1) return (G_BAD_TOK_HEADER); if (*buf++ != MECH_OID) return (G_BAD_TOK_HEADER); - if ((toksize -= 1) < 0) + if (toksize-- < 1) return (G_BAD_TOK_HEADER); toid.length = *buf++; - if ((toksize -= toid.length) < 0) + if (toksize < toid.length) return (G_BAD_TOK_HEADER); + else + toksize -= toid.length; toid.elements = buf; buf += toid.length; @@ -2831,8 +2839,10 @@ g_verify_token_header(gss_OID_const mech, * G_WRONG_MECH is not returned immediately because it's more important * to return G_BAD_TOK_HEADER if the token header is in fact bad */ - if ((toksize -= 2) < 0) + if (toksize < 2) return (G_BAD_TOK_HEADER); + else + toksize -= 2; if (!ret) { *buf_in = buf; diff --git a/src/lib/gssapi32.def b/src/lib/gssapi32.def index 51b7d481b9..5044808e1d 100644 --- a/src/lib/gssapi32.def +++ b/src/lib/gssapi32.def @@ -59,7 +59,7 @@ EXPORTS ; GSS-API v2 future extensions ; gss_inquire_names_for_mech -; gss_inquire_mechs_for_name + gss_inquire_mechs_for_name gss_canonicalize_name gss_export_name gss_duplicate_name @@ -72,6 +72,7 @@ EXPORTS gss_krb5_set_allowable_enctypes gss_krb5_export_lucid_sec_context gss_krb5_free_lucid_sec_context + krb5_gss_register_acceptor_identity ; ; GSS-API variables ; diff --git a/src/lib/kadm5/Makefile.in b/src/lib/kadm5/Makefile.in index a597a360aa..71c14f4bda 100644 --- a/src/lib/kadm5/Makefile.in +++ b/src/lib/kadm5/Makefile.in @@ -98,7 +98,7 @@ clean-unix:: clean-libobjs clean-windows:: -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/kadm5/clnt/Makefile.in b/src/lib/kadm5/clnt/Makefile.in index ed0cb41df2..7edea76983 100644 --- a/src/lib/kadm5/clnt/Makefile.in +++ b/src/lib/kadm5/clnt/Makefile.in @@ -72,8 +72,8 @@ clean-unix:: clean-liblinks clean-libs clean-libobjs install:: install-libs -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/kadm5/logger.c b/src/lib/kadm5/logger.c index 24d845162b..e9c7bfd496 100644 --- a/src/lib/kadm5/logger.c +++ b/src/lib/kadm5/logger.c @@ -510,7 +510,7 @@ krb5_klog_init(krb5_context kcontext, char *ename, char *whoami, krb5_boolean do * If there is a facility present, then parse that. */ if (cp2) { - const struct { + static const struct { const char *name; int value; } facilities[] = { diff --git a/src/lib/kadm5/ovsec_glue.c b/src/lib/kadm5/ovsec_glue.c index 750aa3f812..a3ae6de425 100644 --- a/src/lib/kadm5/ovsec_glue.c +++ b/src/lib/kadm5/ovsec_glue.c @@ -1,5 +1,6 @@ #define USE_KADM5_API_VERSION 1 #include +#include ovsec_kadm_ret_t ovsec_kadm_init_with_password(char *client_name, char *pass, char *service_name, diff --git a/src/lib/kadm5/srv/Makefile.in b/src/lib/kadm5/srv/Makefile.in index 63d9c5ad51..a2ee7f0611 100644 --- a/src/lib/kadm5/srv/Makefile.in +++ b/src/lib/kadm5/srv/Makefile.in @@ -89,8 +89,8 @@ clean-unix:: clean-liblinks clean-libs clean-libobjs install:: install-libs -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/kadm5/srv/server_acl.c b/src/lib/kadm5/srv/server_acl.c index fa63027f7c..6d8d6d7f69 100644 --- a/src/lib/kadm5/srv/server_acl.c +++ b/src/lib/kadm5/srv/server_acl.c @@ -197,7 +197,7 @@ kadm5int_acl_parse_line(lp) for (op=acle_ops; *op; op++) { char rop; - rop = (isupper((int) *op)) ? tolower((int) *op) : *op; + rop = (isupper((unsigned char) *op)) ? tolower((unsigned char) *op) : *op; found = 0; for (t=0; acl_op_table[t].ao_op; t++) { if (rop == acl_op_table[t].ao_op) { diff --git a/src/lib/kadm5/srv/server_misc.c b/src/lib/kadm5/srv/server_misc.c index fa4e62ee43..cd65371c9c 100644 --- a/src/lib/kadm5/srv/server_misc.c +++ b/src/lib/kadm5/srv/server_misc.c @@ -134,17 +134,17 @@ passwd_check(kadm5_server_handle_t handle, return KADM5_PASS_Q_TOOSHORT; s = password; while ((c = *s++)) { - if (islower((int) c)) { + if (islower((unsigned char) c)) { nlower = 1; continue; } - else if (isupper((int) c)) { + else if (isupper((unsigned char) c)) { nupper = 1; continue; - } else if (isdigit((int) c)) { + } else if (isdigit((unsigned char) c)) { ndigit = 1; continue; - } else if (ispunct((int) c)) { + } else if (ispunct((unsigned char) c)) { npunct = 1; continue; } else { diff --git a/src/lib/kadm5/unit-test/init-test.c b/src/lib/kadm5/unit-test/init-test.c index 9677698a79..575b24f353 100644 --- a/src/lib/kadm5/unit-test/init-test.c +++ b/src/lib/kadm5/unit-test/init-test.c @@ -4,6 +4,7 @@ #include #include #include +#include int main() { diff --git a/src/lib/kadm5/unit-test/iter-test.c b/src/lib/kadm5/unit-test/iter-test.c index 4b85a5490d..17e561ef16 100644 --- a/src/lib/kadm5/unit-test/iter-test.c +++ b/src/lib/kadm5/unit-test/iter-test.c @@ -1,5 +1,6 @@ #include #include +#include int main(int argc, char **argv) { diff --git a/src/lib/kadm5/unit-test/lock-test.c b/src/lib/kadm5/unit-test/lock-test.c index 38ad3cdb7e..489b7b88ea 100644 --- a/src/lib/kadm5/unit-test/lock-test.c +++ b/src/lib/kadm5/unit-test/lock-test.c @@ -7,6 +7,7 @@ #include #include #include +#include char *whoami; diff --git a/src/lib/kdb/Makefile.in b/src/lib/kdb/Makefile.in index ff49791477..e6666929c3 100644 --- a/src/lib/kdb/Makefile.in +++ b/src/lib/kdb/Makefile.in @@ -51,8 +51,8 @@ all-unix:: all-liblinks install-unix:: install-libs clean-unix:: clean-liblinks clean-libs clean-libobjs -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/krb4/Makefile.in b/src/lib/krb4/Makefile.in index 9812d15975..b58f785e05 100644 --- a/src/lib/krb4/Makefile.in +++ b/src/lib/krb4/Makefile.in @@ -264,8 +264,8 @@ check-windows:: install-unix:: install-libs -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/krb4/kparse.c b/src/lib/krb4/kparse.c index 190518ad91..f6607a9cad 100644 --- a/src/lib/krb4/kparse.c +++ b/src/lib/krb4/kparse.c @@ -563,8 +563,8 @@ static char * strutol( start ) { char *q; for (q=start; *q; q++) - if (isupper((int) *q)) - *q=tolower((int) *q); + if (isupper((unsigned char) *q)) + *q=tolower((unsigned char) *q); return(start); } diff --git a/src/lib/krb5/Makefile.in b/src/lib/krb5/Makefile.in index fcf2ea28c7..9c6fe864d7 100644 --- a/src/lib/krb5/Makefile.in +++ b/src/lib/krb5/Makefile.in @@ -125,8 +125,8 @@ clean-windows:: install-unix:: install-libs -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/krb5/asn.1/Makefile.in b/src/lib/krb5/asn.1/Makefile.in index 3c440fe561..b39dd2546e 100644 --- a/src/lib/krb5/asn.1/Makefile.in +++ b/src/lib/krb5/asn.1/Makefile.in @@ -52,7 +52,7 @@ all-unix:: all-libobjs clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/krb5/ccache/Makefile.in b/src/lib/krb5/ccache/Makefile.in index 7906aebb00..44ba2a91b6 100644 --- a/src/lib/krb5/ccache/Makefile.in +++ b/src/lib/krb5/ccache/Makefile.in @@ -94,7 +94,7 @@ clean-unix:: ##WIN32## $(OUTPRE)cc_mslsa.$(OBJEXT): cc_mslsa.c $(SRCTOP)/include/k5-int.h $(BUILDTOP)/include/krb5/osconf.h $(BUILDTOP)/include/krb5/autoconf.h $(BUILDTOP)/include/krb5.h $(COM_ERR_DEPS) -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/krb5/ccache/cc_mslsa.c b/src/lib/krb5/ccache/cc_mslsa.c index 6a75aef864..46fa507b31 100644 --- a/src/lib/krb5/ccache/cc_mslsa.c +++ b/src/lib/krb5/ccache/cc_mslsa.c @@ -136,6 +136,43 @@ is_windows_xp (void) return fIsWinXP; } +typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); + +static BOOL +is_broken_wow64(void) +{ + static BOOL fChecked = FALSE; + static BOOL fIsBrokenWow64 = FALSE; + + if (!fChecked) + { + BOOL isWow64 = FALSE; + OSVERSIONINFO Version; + LPFN_ISWOW64PROCESS fnIsWow64Process = + (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle("kernel32"), + "IsWow64Process"); + + /* If we don't find the fnIsWow64Process function then we + * are not running in a broken Wow64 + */ + if (fnIsWow64Process) { + memset (&Version, 0x00, sizeof(Version)); + Version.dwOSVersionInfoSize = sizeof(Version); + + if (fnIsWow64Process(GetCurrentProcess(), &isWow64) && + GetVersionEx (&Version)) { + if (isWow64 && + Version.dwPlatformId == VER_PLATFORM_WIN32_NT && + Version.dwMajorVersion < 6) + fIsBrokenWow64 = TRUE; + } + } + fChecked = TRUE; + } + + return fIsBrokenWow64; +} + /* This flag is only supported by versions of Windows which have obtained * a code change from Microsoft. When the code change is installed, * setting this flag will cause all retrieved credentials to be stored @@ -729,9 +766,9 @@ IsKerberosLogon(VOID) usLength = (pSessionData->AuthenticationPackage).Length; if (usLength < 256) { - lstrcpyn (buffer, usBuffer, usLength); - lstrcat (buffer,L""); - if ( !lstrcmp(L"Kerberos",buffer) ) + lstrcpynW (buffer, usBuffer, usLength); + lstrcatW (buffer,L""); + if ( !lstrcmpW(L"Kerberos",buffer) ) Success = TRUE; } } @@ -1888,7 +1925,7 @@ krb5_lcc_resolve (krb5_context context, krb5_ccache *id, const char *residual) KERB_EXTERNAL_TICKET *msticket; krb5_error_code retval = KRB5_OK; - if (!is_windows_2000()) + if (!is_windows_2000() || is_broken_wow64()) return KRB5_FCC_NOFILE; #ifdef COMMENT diff --git a/src/lib/krb5/ccache/ccapi/stdcc.c b/src/lib/krb5/ccache/ccapi/stdcc.c index 885abf5bb7..ff3e9a8364 100644 --- a/src/lib/krb5/ccache/ccapi/stdcc.c +++ b/src/lib/krb5/ccache/ccapi/stdcc.c @@ -3,8 +3,9 @@ * credentical cache API * * Written by Frank Dabek July 1998 + * Updated by Jeffrey Altman June 2006 * - * Copyright 1998, 1999 by the Massachusetts Institute of Technology. + * Copyright 1998, 1999, 2006 by the Massachusetts Institute of Technology. * All Rights Reserved. * * Export of this software from the United States of America may @@ -28,15 +29,12 @@ * */ -#define NEED_WINDOWS #include "k5-int.h" #include "stdcc.h" #include "stdcc_util.h" #include "string.h" #include -apiCB *gCntrlBlock = NULL; - #if defined(_WIN32) #include "winccld.h" #endif @@ -56,14 +54,37 @@ apiCB *gCntrlBlock = NULL; #define SHOW_DEBUG(buf) #endif +#ifdef USE_CCAPI_V3 +cc_context_t gCntrlBlock = NULL; +#else +apiCB *gCntrlBlock = NULL; +#endif + /* * declare our global object wanna-be * must be installed in ccdefops.c */ krb5_cc_ops krb5_cc_stdcc_ops = { - 0, - "API", + 0, + "API", +#ifdef USE_CCAPI_V3 + krb5_stdccv3_get_name, + krb5_stdccv3_resolve, + krb5_stdccv3_generate_new, + krb5_stdccv3_initialize, + krb5_stdccv3_destroy, + krb5_stdccv3_close, + krb5_stdccv3_store, + krb5_stdccv3_retrieve, + krb5_stdccv3_get_principal, + krb5_stdccv3_start_seq_get, + krb5_stdccv3_next_cred, + krb5_stdccv3_end_seq_get, + krb5_stdccv3_remove, + krb5_stdccv3_set_flags, + krb5_stdccv3_get_flags +#else krb5_stdcc_get_name, krb5_stdcc_resolve, krb5_stdcc_generate_new, @@ -78,7 +99,8 @@ krb5_cc_ops krb5_cc_stdcc_ops = { krb5_stdcc_end_seq_get, krb5_stdcc_remove, krb5_stdcc_set_flags, - krb5_stdcc_get_flags, + krb5_stdcc_get_flags +#endif }; #if defined(_WIN32) @@ -114,6 +136,36 @@ struct err_xlate static const struct err_xlate err_xlate_table[] = { +#ifdef USE_CCAPI_V3 + { ccIteratorEnd, KRB5_CC_END }, + { ccErrBadParam, KRB5_FCC_INTERNAL }, + { ccErrNoMem, KRB5_CC_NOMEM }, + { ccErrInvalidContext, KRB5_FCC_INTERNAL }, + { ccErrInvalidCCache, KRB5_FCC_INTERNAL }, + { ccErrInvalidString, KRB5_FCC_INTERNAL }, + { ccErrInvalidCredentials, KRB5_FCC_INTERNAL }, + { ccErrInvalidCCacheIterator, KRB5_FCC_INTERNAL }, + { ccErrInvalidCredentialsIterator, KRB5_FCC_INTERNAL }, + { ccErrInvalidLock, KRB5_FCC_INTERNAL }, + { ccErrBadName, KRB5_CC_BADNAME }, + { ccErrBadCredentialsVersion, KRB5_FCC_INTERNAL }, + { ccErrBadAPIVersion, KRB5_FCC_INTERNAL }, + { ccErrContextLocked, KRB5_FCC_INTERNAL }, + { ccErrContextUnlocked, KRB5_FCC_INTERNAL }, + { ccErrCCacheLocked, KRB5_FCC_INTERNAL }, + { ccErrCCacheUnlocked, KRB5_FCC_INTERNAL }, + { ccErrBadLockType, KRB5_FCC_INTERNAL }, + { ccErrNeverDefault, KRB5_FCC_INTERNAL }, + { ccErrCredentialsNotFound, KRB5_CC_NOTFOUND }, + { ccErrCCacheNotFound, KRB5_FCC_NOFILE }, + { ccErrContextNotFound, KRB5_FCC_INTERNAL }, + { ccErrServerUnavailable, KRB5_FCC_NOFILE }, + { ccErrServerInsecure, KRB5_FCC_INTERNAL }, + { ccErrServerCantBecomeUID, KRB5_FCC_INTERNAL }, + { ccErrTimeOffsetNotSet, KRB5_FCC_INTERNAL }, + { ccErrBadInternalMessage, KRB5_FCC_INTERNAL }, + { ccErrNotImplemented, KRB5_FCC_INTERNAL }, +#else { CC_BADNAME, KRB5_CC_BADNAME }, { CC_NOTFOUND, KRB5_CC_NOTFOUND }, { CC_END, KRB5_CC_END }, @@ -131,6 +183,7 @@ static const struct err_xlate err_xlate_table[] = { CC_ERR_CACHE_RELEASE, KRB5_FCC_INTERNAL /* XXX */ }, { CC_ERR_CACHE_FULL, KRB5_FCC_INTERNAL /* XXX */ }, { CC_ERR_CRED_VERSION, KRB5_FCC_INTERNAL /* XXX */ }, +#endif { 0, 0 } }; @@ -138,8 +191,13 @@ static krb5_error_code cc_err_xlate(int err) { const struct err_xlate *p; - if (err == CC_NOERROR) +#ifdef USE_CCAPI_V3 + if (err == ccNoError) return 0; +#else + if (err == CC_NOERROR) + return 0; +#endif for (p = err_xlate_table; p->cc_err; p++) { if (err == p->cc_err) @@ -148,6 +206,537 @@ static krb5_error_code cc_err_xlate(int err) return KRB5_FCC_INTERNAL; /* XXX we need a miscellaneous return */ } + +#ifdef USE_CCAPI_V3 +static krb5_error_code stdccv3_setup(krb5_context context, + stdccCacheDataPtr ccapi_data) +{ + cc_int32 err; + + /* make sure the API has been intialized */ + if (gCntrlBlock == NULL) { + err = cc_initialize(&gCntrlBlock, ccapi_version_max, NULL, NULL); + if (err != ccNoError) + return cc_err_xlate(err); + } + + /* + * No ccapi_data structure, so we don't need to make sure the + * ccache exists. + */ + if (!ccapi_data) + return 0; + + /* + * The ccache already exists + */ + if (ccapi_data->NamedCache) + return 0; + + err = cc_context_open_ccache(gCntrlBlock, ccapi_data->cache_name, + &ccapi_data->NamedCache); + if (err == ccNoError) + return 0; + + ccapi_data->NamedCache = NULL; + return cc_err_xlate(err); +} + +/* krb5_stdcc_shutdown is exported; use the old name */ +void krb5_stdcc_shutdown() +{ + if (gCntrlBlock) + cc_context_release(gCntrlBlock); + gCntrlBlock = NULL; +} + +/* + * -- generate_new -------------------------------- + * + * create a new cache with a unique name, corresponds to creating a + * named cache initialize the API here if we have to. + */ +krb5_error_code KRB5_CALLCONV krb5_stdccv3_generate_new + (krb5_context context, krb5_ccache *id ) +{ + krb5_ccache newCache = NULL; + krb5_error_code retval; + stdccCacheDataPtr ccapi_data = NULL; + char *name = NULL; + cc_time time; + int err; + + if ((retval = stdccv3_setup(context, NULL))) + return retval; + + retval = KRB5_CC_NOMEM; + if (!(newCache = (krb5_ccache) malloc(sizeof(struct _krb5_ccache)))) + goto errout; + if (!(ccapi_data = (stdccCacheDataPtr)malloc(sizeof(stdccCacheData)))) + goto errout; + if (!(name = malloc(256))) + goto errout; + + /* create a unique name */ + if (retval = cc_context_get_change_time(gCntrlBlock, &time)) + goto errout; + sprintf(name, "gen_new_cache%d", time); + + /* create the new cache */ + err = cc_context_create_ccache(gCntrlBlock, name, cc_credentials_v5, 0L, + &ccapi_data->NamedCache); + if (err != ccNoError) { + retval = cc_err_xlate(err); + goto errout; + } + + /* setup some fields */ + newCache->ops = &krb5_cc_stdcc_ops; + newCache->data = ccapi_data; + ccapi_data->cache_name = name; + + /* return a pointer to the new cache */ + *id = newCache; + + return 0; + +errout: + if (newCache) + free(newCache); + if (ccapi_data) + free(ccapi_data); + if (name) + free(name); + return retval; +} + +/* + * resolve + * + * create a new cache with the name stored in residual + */ +krb5_error_code KRB5_CALLCONV krb5_stdccv3_resolve + (krb5_context context, krb5_ccache *id , const char *residual ) +{ + krb5_ccache newCache = NULL; + stdccCacheDataPtr ccapi_data = NULL; + int err; + krb5_error_code retval; + char *cName = NULL; + + if ((retval = stdccv3_setup(context, NULL))) + return retval; + + retval = KRB5_CC_NOMEM; + if (!(newCache = (krb5_ccache) malloc(sizeof(struct _krb5_ccache)))) + goto errout; + + if (!(ccapi_data = (stdccCacheDataPtr)malloc(sizeof(stdccCacheData)))) + goto errout; + + if (!(cName = malloc(strlen(residual)+1))) + goto errout; + + newCache->ops = &krb5_cc_stdcc_ops; + newCache->data = ccapi_data; + ccapi_data->cache_name = cName; + + strcpy(cName, residual); + + err = cc_context_open_ccache(gCntrlBlock, cName, + &ccapi_data->NamedCache); + if (err != ccNoError) { + ccapi_data->NamedCache = NULL; + goto errout; + } + + /* return new cache structure */ + *id = newCache; + + return 0; + +errout: + if (newCache) + free(newCache); + if (ccapi_data) + free(ccapi_data); + if (cName) + free(cName); + return retval; +} + +/* + * initialize + * + * initialize the cache, check to see if one already exists for this + * principal if not set our principal to this principal. This + * searching enables ticket sharing + */ +krb5_error_code KRB5_CALLCONV krb5_stdccv3_initialize + (krb5_context context, krb5_ccache id, krb5_principal princ) +{ + stdccCacheDataPtr ccapi_data = NULL; + int err; + char *cName = NULL; + krb5_error_code retval; + + if ((retval = stdccv3_setup(context, NULL))) + return retval; + + /* test id for null */ + if (id == NULL) return KRB5_CC_NOMEM; + + if ((retval = krb5_unparse_name(context, princ, &cName))) + return retval; + + ccapi_data = id->data; + + + if (ccapi_data->NamedCache) { + err = cc_ccache_release(ccapi_data->NamedCache); + ccapi_data->NamedCache = NULL; + } + + err = cc_context_create_ccache(gCntrlBlock, ccapi_data->cache_name, + cc_credentials_v5, cName, + &ccapi_data->NamedCache); + if (err != ccNoError) { + krb5_free_unparsed_name(context, cName); + return cc_err_xlate(err); + } + + krb5_free_unparsed_name(context, cName); + cache_changed(); + + return cc_err_xlate(err); +} + +/* + * store + * + * store some credentials in our cache + */ +krb5_error_code KRB5_CALLCONV krb5_stdccv3_store + (krb5_context context, krb5_ccache id, krb5_creds *creds ) +{ + krb5_error_code retval; + stdccCacheDataPtr ccapi_data = id->data; + cc_credentials_t c = NULL; + int err; + + if ((retval = stdccv3_setup(context, ccapi_data))) + return retval; + + /* copy the fields from the almost identical structures */ + dupK5toCC3(context, creds, &c); + + /* + * finally store the credential + * store will copy (that is duplicate) everything + */ + err = cc_ccache_store_credentials(((stdccCacheDataPtr)(id->data))->NamedCache, c->data); + if (err != ccNoError) + return cc_err_xlate(err); + + err = cc_credentials_release(c); + + cache_changed(); + return err; +} + +/* + * start_seq_get + * + * begin an iterator call to get all of the credentials in the cache + */ +krb5_error_code KRB5_CALLCONV krb5_stdccv3_start_seq_get +(krb5_context context, krb5_ccache id , krb5_cc_cursor *cursor ) +{ + stdccCacheDataPtr ccapi_data = id->data; + krb5_error_code retval; + int err; + cc_credentials_iterator_t iterator; + + if ((retval = stdccv3_setup(context, ccapi_data))) + return retval; + + err = cc_ccache_new_credentials_iterator(ccapi_data->NamedCache, + &iterator); + if (err != ccNoError) + return cc_err_xlate(err); + *cursor = iterator; + return 0; +} + +/* + * next cred + * + * - get the next credential in the cache as part of an iterator call + * - this maps to call to cc_seq_fetch_creds + */ +krb5_error_code KRB5_CALLCONV krb5_stdccv3_next_cred + (krb5_context context, krb5_ccache id, krb5_cc_cursor *cursor, + krb5_creds *creds) +{ + krb5_error_code retval; + stdccCacheDataPtr ccapi_data = id->data; + int err; + cc_credentials_t cu; + cc_credentials_iterator_t iterator; + + if ((retval = stdccv3_setup(context, ccapi_data))) + return retval; + + iterator = *cursor; + if (iterator == 0) + return KRB5_CC_END; + err = cc_credentials_iterator_next(iterator, &cu); + + if (err == ccIteratorEnd) { + cc_credentials_iterator_release(iterator); + *cursor = 0; + } + if (err != ccNoError) + return cc_err_xlate(err); + + /* copy data (with translation) */ + dupCC3toK5(context, cu, creds); + + cc_credentials_release(cu); + + return 0; +} + + +/* + * retrieve + * + * - try to find a matching credential in the cache + */ +krb5_error_code KRB5_CALLCONV +krb5_stdccv3_retrieve(context, id, whichfields, mcreds, creds) + krb5_context context; + krb5_ccache id; + krb5_flags whichfields; + krb5_creds *mcreds; + krb5_creds *creds; +{ + return krb5_cc_retrieve_cred_default (context, id, whichfields, + mcreds, creds); +} + +/* + * end seq + * + * just free up the storage assoicated with the cursor (if we can) + */ +krb5_error_code KRB5_CALLCONV krb5_stdccv3_end_seq_get + (krb5_context context, krb5_ccache id, krb5_cc_cursor *cursor) +{ + krb5_error_code retval; + stdccCacheDataPtr ccapi_data = NULL; + int err; + cc_credentials_iterator_t iterator; + + ccapi_data = id->data; + + if ((retval = stdccv3_setup(context, ccapi_data))) + return retval; + + if (*cursor == NULL) + return 0; + + iterator = *cursor; + + err = cc_credentials_iterator_release(iterator); + if (err != ccNoError) + return cc_err_xlate(err); + return(0); +} + +/* + * close + * + * - free our pointers to the NC + */ +krb5_error_code KRB5_CALLCONV +krb5_stdccv3_close(krb5_context context, krb5_ccache id) +{ + krb5_error_code retval; + stdccCacheDataPtr ccapi_data = id->data; + + if ((retval = stdccv3_setup(context, NULL))) + return retval; + + /* free it */ + if (ccapi_data) { + if (ccapi_data->cache_name) + free(ccapi_data->cache_name); + if (ccapi_data->NamedCache) + cc_ccache_release(ccapi_data->NamedCache); + free(ccapi_data); + id->data = NULL; + } + free(id); + + return 0; +} + +/* + * destroy + * + * - free our storage and the cache + */ +krb5_error_code KRB5_CALLCONV +krb5_stdccv3_destroy (krb5_context context, krb5_ccache id) +{ + int err; + krb5_error_code retval; + stdccCacheDataPtr ccapi_data = id->data; + + if ((retval = stdccv3_setup(context, ccapi_data))) { + return retval; + } + + /* free memory associated with the krb5_ccache */ + if (ccapi_data) { + if (ccapi_data->cache_name) + free(ccapi_data->cache_name); + if (ccapi_data->NamedCache) { + /* destroy the named cache */ + err = cc_ccache_destroy(ccapi_data->NamedCache); + retval = cc_err_xlate(err); + cache_changed(); + } + free(ccapi_data); + id->data = NULL; + } + free(id); + + /* If the cache does not exist when we tried to destroy it, + that's fine. That means someone else destroyed it since + we resolved it. */ + if (retval == ccErrCCacheNotFound) + return 0; + return retval; +} + +/* + * getname + * + * - return the name of the named cache + */ +const char * KRB5_CALLCONV krb5_stdccv3_get_name + (krb5_context context, krb5_ccache id ) +{ + stdccCacheDataPtr ccapi_data = id->data; + + if (!ccapi_data) + return 0; + + return (ccapi_data->cache_name); +} + + +/* get_principal + * + * - return the principal associated with the named cache + */ +krb5_error_code KRB5_CALLCONV krb5_stdccv3_get_principal + (krb5_context context, krb5_ccache id , krb5_principal *princ) +{ + int err; + cc_string_t name = NULL; + stdccCacheDataPtr ccapi_data = id->data; + krb5_error_code retval; + + if ((retval = stdccv3_setup(context, ccapi_data))) + return retval; + + /* another wrapper */ + err = cc_ccache_get_principal(ccapi_data->NamedCache, cc_credentials_v5, &name); + + if (err != ccNoError) + return cc_err_xlate(err); + + /* turn it into a krb principal */ + err = krb5_parse_name(context, name->data, princ); + + cc_string_release(name); + + return err; +} + +/* + * set_flags + * + * - currently a NOP since we don't store any flags in the NC + */ +krb5_error_code KRB5_CALLCONV krb5_stdccv3_set_flags + (krb5_context context, krb5_ccache id , krb5_flags flags) +{ + stdccCacheDataPtr ccapi_data = id->data; + krb5_error_code retval; + + if ((retval = stdccv3_setup(context, ccapi_data))) + return retval; + + return 0; +} + +/* + * get_flags + * + * - currently a NOP since we don't store any flags in the NC + */ +krb5_error_code KRB5_CALLCONV krb5_stdccv3_get_flags + (krb5_context context, krb5_ccache id , krb5_flags *flags) +{ + stdccCacheDataPtr ccapi_data = id->data; + krb5_error_code retval; + + if ((retval = stdccv3_setup(context, ccapi_data))) + return retval; + + return 0; +} + +/* + * remove + * + * - remove the specified credentials from the NC + */ +krb5_error_code KRB5_CALLCONV krb5_stdccv3_remove + (krb5_context context, krb5_ccache id, + krb5_flags flags, krb5_creds *creds) +{ + cc_credentials_t c = NULL; + int err; + stdccCacheDataPtr ccapi_data = id->data; + krb5_error_code retval; + + if ((retval = stdccv3_setup(context, ccapi_data))) { + if (retval == KRB5_FCC_NOFILE) + return 0; + return retval; + } + + /* convert to a cred union */ + dupK5toCC3(context, creds, &c); + + /* remove it */ + err = cc_ccache_remove_credentials(ccapi_data->NamedCache, c); + if (err != ccNoError) + return cc_err_xlate(err); + + err = cc_credentials_release(c); + cache_changed(); + if (err != ccNoError) + return cc_err_xlate(err); + + return 0; +} +#else /* !USE_CCAPI_V3 */ static krb5_error_code stdcc_setup(krb5_context context, stdccCacheDataPtr ccapi_data) { @@ -192,7 +781,7 @@ void krb5_stdcc_shutdown() { if (gCntrlBlock) cc_shutdown(&gCntrlBlock); - gCntrlBlock = 0; + gCntrlBlock = NULL; } /* @@ -289,9 +878,10 @@ krb5_error_code KRB5_CALLCONV krb5_stdcc_resolve err = cc_open(gCntrlBlock, cName, CC_CRED_V5, 0L, &ccapi_data->NamedCache); - if (err != CC_NOERROR) - ccapi_data->NamedCache = NULL; - + if (err != CC_NOERROR) { + ccapi_data->NamedCache = NULL; + goto errout; + } /* return new cache structure */ *id = newCache; @@ -388,7 +978,7 @@ krb5_error_code KRB5_CALLCONV krb5_stdcc_store /* free the cred union using our local version of cc_free_creds() since we allocated it locally */ - err = krb5_free_cc_cred_union(&cu); + err = krb5int_free_cc_cred_union(&cu); cache_changed(); return err; @@ -523,7 +1113,6 @@ krb5_error_code KRB5_CALLCONV krb5_stdcc_retrieve return KRB5_CC_NOTFOUND; } #else -#include "k5-int.h" krb5_error_code KRB5_CALLCONV krb5_stdcc_retrieve(context, id, whichfields, mcreds, creds) @@ -763,10 +1352,11 @@ krb5_error_code KRB5_CALLCONV krb5_stdcc_remove /* free the cred union using our local version of cc_free_creds() since we allocated it locally */ - err = krb5_free_cc_cred_union(&cu); + err = krb5int_free_cc_cred_union(&cu); cache_changed(); if (err != CC_NOERROR) return cc_err_xlate(err); return 0; } +#endif /* !USE_CCAPI_V3 */ \ No newline at end of file diff --git a/src/lib/krb5/ccache/ccapi/stdcc.h b/src/lib/krb5/ccache/ccapi/stdcc.h index 81ce883cb6..c0ce13b420 100644 --- a/src/lib/krb5/ccache/ccapi/stdcc.h +++ b/src/lib/krb5/ccache/ccapi/stdcc.h @@ -1,13 +1,17 @@ -#include "krb5.h" -#include "k5-int.h" +#include "k5-int.h" /* loads krb5.h */ +#ifdef USE_CCAPI_V3 +#include +#else #ifdef USE_CCAPI #include -#endif - +#else #if defined(_WIN32) #include "cacheapi.h" #endif +#endif +#endif + #define kStringLiteralLen 255 @@ -19,12 +23,71 @@ extern krb5_cc_ops krb5_cc_stdcc_ops; */ typedef struct _stdccCacheData { char *cache_name; +#ifdef USE_CCAPI_V3 + cc_ccache_t NamedCache; +#else ccache_p *NamedCache; +#endif } stdccCacheData, *stdccCacheDataPtr; /* function protoypes */ +#ifdef USE_CCAPI_V3 +void krb5_stdccv3_shutdown(void); + +krb5_error_code KRB5_CALLCONV krb5_stdccv3_close + (krb5_context, krb5_ccache id ); + +krb5_error_code KRB5_CALLCONV krb5_stdccv3_destroy + (krb5_context, krb5_ccache id ); + +krb5_error_code KRB5_CALLCONV krb5_stdccv3_end_seq_get + (krb5_context, krb5_ccache id , krb5_cc_cursor *cursor ); + +krb5_error_code KRB5_CALLCONV krb5_stdccv3_generate_new + (krb5_context, krb5_ccache *id ); + +const char * KRB5_CALLCONV krb5_stdccv3_get_name + (krb5_context, krb5_ccache id ); + +krb5_error_code KRB5_CALLCONV krb5_stdccv3_get_principal + (krb5_context, krb5_ccache id , krb5_principal *princ ); + +krb5_error_code KRB5_CALLCONV krb5_stdccv3_initialize + (krb5_context, krb5_ccache id , krb5_principal princ ); + +krb5_error_code KRB5_CALLCONV krb5_stdccv3_next_cred + (krb5_context, + krb5_ccache id , + krb5_cc_cursor *cursor , + krb5_creds *creds ); + +krb5_error_code KRB5_CALLCONV krb5_stdccv3_resolve + (krb5_context, krb5_ccache *id , const char *residual ); + +krb5_error_code KRB5_CALLCONV krb5_stdccv3_retrieve + (krb5_context, + krb5_ccache id , + krb5_flags whichfields , + krb5_creds *mcreds , + krb5_creds *creds ); + +krb5_error_code KRB5_CALLCONV krb5_stdccv3_start_seq_get + (krb5_context, krb5_ccache id , krb5_cc_cursor *cursor ); + +krb5_error_code KRB5_CALLCONV krb5_stdccv3_store + (krb5_context, krb5_ccache id , krb5_creds *creds ); + +krb5_error_code KRB5_CALLCONV krb5_stdccv3_set_flags + (krb5_context, krb5_ccache id , krb5_flags flags ); + +krb5_error_code KRB5_CALLCONV krb5_stdccv3_get_flags + (krb5_context, krb5_ccache id , krb5_flags *flags ); + +krb5_error_code KRB5_CALLCONV krb5_stdccv3_remove + (krb5_context, krb5_ccache id , krb5_flags flags, krb5_creds *creds); +#else void krb5_stdcc_shutdown(void); krb5_error_code KRB5_CALLCONV krb5_stdcc_close @@ -78,3 +141,4 @@ krb5_error_code KRB5_CALLCONV krb5_stdcc_get_flags krb5_error_code KRB5_CALLCONV krb5_stdcc_remove (krb5_context, krb5_ccache id , krb5_flags flags, krb5_creds *creds); +#endif \ No newline at end of file diff --git a/src/lib/krb5/ccache/ccapi/stdcc_util.c b/src/lib/krb5/ccache/ccapi/stdcc_util.c index 7f9358dca5..1969b6e718 100644 --- a/src/lib/krb5/ccache/ccapi/stdcc_util.c +++ b/src/lib/krb5/ccache/ccapi/stdcc_util.c @@ -19,6 +19,401 @@ #define fieldSize 255 +#ifdef USE_CCAPI_V3 +/* krb5int_cc_credentials_release(cc_credentials_t creds) + * - function used to release internally generated cc_credentials_t objects + */ +static cc_int32 +krb5int_cc_credentials_release(cc_credentials_t creds) { + free(creds); + return ccNoError; +} + +static cc_int32 +krb5int_cc_credentials_compare(cc_credentials_t creds, + cc_credentials_t compare_to, + cc_uint32* equal) { + return ccErrNotImplemented; +} + +/* + * CopyCC3DataArrayToK5 + * - copy and translate the null terminated arrays of data records + * used in k5 tickets + */ +int +copyCC3DataArrayToK5(cc_credentials_v5_t *ccCreds, krb5_creds *v5Creds, char whichArray) { + + switch (whichArray) { + case kAddressArray: + if (ccCreds->addresses == NULL) { + v5Creds->addresses = NULL; + } else { + + krb5_address **addrPtr, *addr; + cc_data **dataPtr, *data; + unsigned int numRecords = 0; + + /* Allocate the array of pointers: */ + for (dataPtr = ccCreds->addresses; *dataPtr != NULL; numRecords++, dataPtr++) {} + + v5Creds->addresses = (krb5_address **) malloc (sizeof(krb5_address *) * (numRecords + 1)); + if (v5Creds->addresses == NULL) + return ENOMEM; + + /* Fill in the array, allocating the address structures: */ + for (dataPtr = ccCreds->addresses, addrPtr = v5Creds->addresses; *dataPtr != NULL; addrPtr++, dataPtr++) { + + *addrPtr = (krb5_address *) malloc (sizeof(krb5_address)); + if (*addrPtr == NULL) + return ENOMEM; + data = *dataPtr; + addr = *addrPtr; + + addr->addrtype = data->type; + addr->magic = KV5M_ADDRESS; + addr->length = data->length; + addr->contents = (krb5_octet *) malloc (sizeof(krb5_octet) * addr->length); + if (addr->contents == NULL) + return ENOMEM; + memmove(addr->contents, data->data, addr->length); /* copy contents */ + } + + /* Write terminator: */ + *addrPtr = NULL; + } + break; + case kAuthDataArray: + if (ccCreds->authdata == NULL) { + v5Creds->authdata = NULL; + } else { + krb5_authdata **authPtr, *auth; + cc_data **dataPtr, *data; + unsigned int numRecords = 0; + + /* Allocate the array of pointers: */ + for (dataPtr = ccCreds->authdata; *dataPtr != NULL; numRecords++, dataPtr++) {} + + v5Creds->authdata = (krb5_authdata **) malloc (sizeof(krb5_authdata *) * (numRecords + 1)); + if (v5Creds->authdata == NULL) + return ENOMEM; + + /* Fill in the array, allocating the address structures: */ + for (dataPtr = ccCreds->authdata, authPtr = v5Creds->authdata; *dataPtr != NULL; authPtr++, dataPtr++) { + + *authPtr = (krb5_authdata *) malloc (sizeof(krb5_authdata)); + if (*authPtr == NULL) + return ENOMEM; + data = *dataPtr; + auth = *authPtr; + + auth->ad_type = data->type; + auth->magic = KV5M_AUTHDATA; + auth->length = data->length; + auth->contents = (krb5_octet *) malloc (sizeof(krb5_octet) * auth->length); + if (auth->contents == NULL) + return ENOMEM; + memmove(auth->contents, data->data, auth->length); /* copy contents */ + } + + /* Write terminator: */ + *authPtr = NULL; + } + break; + } + + return 0; +} + +/* + * copyK5DataArrayToCC + * - analagous to above, but in the other direction + */ +int +copyK5DataArrayToCC3(krb5_creds *v5Creds, cc_credentials_v5_t * ccCreds, char whichArray) +{ + switch (whichArray) { + case kAddressArray: + if (v5Creds->addresses == NULL) { + ccCreds->addresses = NULL; + } else { + + krb5_address **addrPtr, *addr; + cc_data **dataPtr, *data; + unsigned int numRecords = 0; + + /* Allocate the array of pointers: */ + for (addrPtr = v5Creds->addresses; *addrPtr != NULL; numRecords++, addrPtr++) {} + + ccCreds->addresses = (cc_data **) malloc (sizeof(cc_data *) * (numRecords + 1)); + if (ccCreds->addresses == NULL) + return ENOMEM; + + /* Fill in the array, allocating the address structures: */ + for (dataPtr = ccCreds->addresses, addrPtr = v5Creds->addresses; *addrPtr != NULL; addrPtr++, dataPtr++) { + + *dataPtr = (cc_data *) malloc (sizeof(cc_data)); + if (*dataPtr == NULL) + return ENOMEM; + data = *dataPtr; + addr = *addrPtr; + + data->type = addr->addrtype; + data->length = addr->length; + data->data = malloc (sizeof(char) * data->length); + if (data->data == NULL) + return ENOMEM; + memmove(data->data, addr->contents, data->length); /* copy contents */ + } + + /* Write terminator: */ + *dataPtr = NULL; + } + break; + case kAuthDataArray: + if (v5Creds->authdata == NULL) { + ccCreds->authdata = NULL; + } else { + krb5_authdata **authPtr, *auth; + cc_data **dataPtr, *data; + unsigned int numRecords = 0; + + /* Allocate the array of pointers: */ + for (authPtr = v5Creds->authdata; *authPtr != NULL; numRecords++, authPtr++) {} + + ccCreds->authdata = (cc_data **) malloc (sizeof(cc_data *) * (numRecords + 1)); + if (ccCreds->authdata == NULL) + return ENOMEM; + + /* Fill in the array, allocating the address structures: */ + for (dataPtr = ccCreds->authdata, authPtr = v5Creds->authdata; *authPtr != NULL; authPtr++, dataPtr++) { + + *dataPtr = (cc_data *) malloc (sizeof(cc_data)); + if (*dataPtr == NULL) + return ENOMEM; + data = *dataPtr; + auth = *authPtr; + + data->type = auth->ad_type; + data->length = auth->length; + data->data = malloc (sizeof(char) * data->length); + if (data->data == NULL) + return ENOMEM; + memmove(data->data, auth->contents, data->length); /* copy contents */ + } + + /* Write terminator: */ + *dataPtr = NULL; + } + break; + } + + return 0; + +} + +/* + * dupCC3toK5 + * - allocate an empty k5 style ticket and copy info from the cc_creds ticket + */ + +krb5_error_code +dupCC3toK5(krb5_context context, cc_credentials_t src, krb5_creds *dest) +{ + const cc_credentials_union *cu = src->data; + cc_credentials_v5_t *cv5; + krb5_int32 offset_seconds = 0, offset_microseconds = 0; + krb5_error_code err; + + if (cu->version != cc_credentials_v5) + return KRB5_CC_NOT_KTYPE; + + cv5 = cu->credentials.credentials_v5; + + /* + * allocate and copy + * copy all of those damn fields back + */ + err = krb5_parse_name(context, cv5->client, &(dest->client)); + err = krb5_parse_name(context, cv5->server, &(dest->server)); + if (err) + return err; /* parsename fails w/o krb5.ini for example */ + + /* copy keyblock */ + dest->keyblock.enctype = cv5->keyblock.type; + dest->keyblock.length = cv5->keyblock.length; + dest->keyblock.contents = (krb5_octet *)malloc(dest->keyblock.length); + memcpy(dest->keyblock.contents, cv5->keyblock.data, dest->keyblock.length); + + /* copy times */ +#if TARGET_OS_MAC + err = krb5_get_time_offsets(context, &offset_seconds, &offset_microseconds); + if (err) + return err; +#endif + dest->times.authtime = cv5->authtime + offset_seconds; + dest->times.starttime = cv5->starttime + offset_seconds; + dest->times.endtime = cv5->endtime + offset_seconds; + dest->times.renew_till = cv5->renew_till + offset_seconds; + dest->is_skey = cv5->is_skey; + dest->ticket_flags = cv5->ticket_flags; + + /* more branching fields */ + err = copyCC3DataArrayToK5(cv5, dest, kAddressArray); + if (err) + return err; + + /* first ticket */ + dest->ticket.length = cv5->ticket.length; + dest->ticket.data = (char *)malloc(cv5->ticket.length); + memcpy(dest->ticket.data, cv5->ticket.data, cv5->ticket.length); + + /* second ticket */ + dest->second_ticket.length = cv5->second_ticket.length; + (dest->second_ticket).data = ( char *)malloc(cv5->second_ticket.length); + memcpy(dest->second_ticket.data, cv5->second_ticket.data, cv5->second_ticket.length); + + /* zero out magic number */ + dest->magic = 0; + + /* authdata */ + err = copyCC3DataArrayToK5(cv5, dest, kAuthDataArray); + if (err) + return err; + + return 0; +} + +/* + * dupK5toCC3 + * - analagous to above but in the reverse direction + */ +krb5_error_code +dupK5toCC3(krb5_context context, krb5_creds *src, cc_credentials_t *dest) +{ + cc_credentials_v5_t *c; + cc_credentials_union *cu; + cc_credentials_f *f; + int err; + krb5_int32 offset_seconds = 0, offset_microseconds = 0; + cc_credentials_t creds = NULL; + + if (dest == NULL) + return KRB5_CC_NOMEM; + + /* allocate the cc_credentials_t */ + creds = (cc_credentials_t)malloc(sizeof(cc_credentials_d)); + if (!creds) { + err = KRB5_CC_NOMEM; + goto cleanup; + } + + /* allocate the cred_union */ + creds->data = NULL; + creds->functions = NULL; +#ifdef TARGET_OS_MAC + creds->otherFunctions = NULL; +#endif + f = (cc_credentials_f *)malloc(sizeof(cc_credentials_f)); + if (!f) { + err = KRB5_CC_NOMEM; + goto cleanup; + } + creds->functions = f; + + cu = (cc_credentials_union *)malloc(sizeof(cc_credentials_union)); + if (!creds->data) { + err = KRB5_CC_NOMEM; + goto cleanup; + } + creds->data = cu; + + f->release = krb5int_cc_credentials_release; + f->compare = krb5int_cc_credentials_compare; + + cu->version = cc_credentials_v5; + + c = (cc_credentials_v5_t*)malloc(sizeof(cc_credentials_v5_t)); + if (!c) { + err = KRB5_CC_NOMEM; + goto cleanup; + } + cu->credentials.credentials_v5 = c; + + /* convert krb5 principals to flat principals */ + err = krb5_unparse_name(context, src->client, &(c->client)); + if (err) + goto cleanup; + + err = krb5_unparse_name(context, src->server, &(c->server)); + if (err) + goto cleanup; + + /* copy more fields */ + c->keyblock.type = src->keyblock.enctype; + c->keyblock.length = src->keyblock.length; + + if (src->keyblock.contents != NULL) { + c->keyblock.data = (unsigned char *)malloc(src->keyblock.length); + memcpy(c->keyblock.data, src->keyblock.contents, src->keyblock.length); + } else { + c->keyblock.data = NULL; + } + +#if TARGET_OS_MAC + err = krb5_get_time_offsets(context, &offset_seconds, &offset_microseconds); + if (err) + goto cleanup; +#endif + c->authtime = src->times.authtime - offset_seconds; + c->starttime = src->times.starttime - offset_seconds; + c->endtime = src->times.endtime - offset_seconds; + c->renew_till = src->times.renew_till - offset_seconds; + c->is_skey = src->is_skey; + c->ticket_flags = src->ticket_flags; + + err = copyK5DataArrayToCC3(src, c, kAddressArray); + if (err) + goto cleanup; + + c->ticket.length = src->ticket.length; + if (src->ticket.data != NULL) { + c->ticket.data = (unsigned char *)malloc(src->ticket.length); + memcpy(c->ticket.data, src->ticket.data, src->ticket.length); + } else { + c->ticket.data = NULL; + } + + c->second_ticket.length = src->second_ticket.length; + if (src->second_ticket.data != NULL) { + c->second_ticket.data = (unsigned char *)malloc(src->second_ticket.length); + memcpy(c->second_ticket.data, src->second_ticket.data, src->second_ticket.length); + } else { + c->second_ticket.data = NULL; + } + + err = copyK5DataArrayToCC3(src, c, kAuthDataArray); + if (err) + goto cleanup; + + *dest = creds; + return 0; + + cleanup: + if (creds) { + if (creds->functions) + free((void *)creds->functions); + if (creds->data) { + if (creds->data->credentials.credentials_v5) + free(creds->data->credentials.credentials_v5); + free((void *)creds->data); + } + free(creds); + } + + return err; +} +#else /* !USE_CCAPI_V3 */ /* * CopyCCDataArrayToK5 * - copy and translate the null terminated arrays of data records @@ -323,6 +718,86 @@ void dupK5toCC(krb5_context context, krb5_creds *creds, cred_union **cu) return; } +/* ----- free_cc_cred_union, etc -------------- */ +/* + Since the Kerberos5 library allocates a credentials cache structure + (in dupK5toCC() above) with its own memory allocation routines - which + may be different than how the CCache allocates memory - the Kerb5 library + must have its own version of cc_free_creds() to deallocate it. These + functions do that. The top-level function to substitue for cc_free_creds() + is krb5_free_cc_cred_union(). + + If the CCache library wants to use a cred_union structure created by + the Kerb5 library, it should make a deep copy of it to "translate" to its + own memory allocation space. +*/ +static void deep_free_cc_data (cc_data data) +{ + if (data.data != NULL) + free (data.data); +} + +static void deep_free_cc_data_array (cc_data** data) { + + unsigned int index; + + if (data == NULL) + return; + + for (index = 0; data [index] != NULL; index++) { + deep_free_cc_data (*(data [index])); + free (data [index]); + } + + free (data); +} + +static void deep_free_cc_v5_creds (cc_creds* creds) +{ + if (creds == NULL) + return; + + if (creds -> client != NULL) + free (creds -> client); + if (creds -> server != NULL) + free (creds -> server); + + deep_free_cc_data (creds -> keyblock); + deep_free_cc_data (creds -> ticket); + deep_free_cc_data (creds -> second_ticket); + + deep_free_cc_data_array (creds -> addresses); + deep_free_cc_data_array (creds -> authdata); + + free(creds); +} + +static void deep_free_cc_creds (cred_union creds) +{ + if (creds.cred_type == CC_CRED_V4) { + /* we shouldn't get this, of course */ + free (creds.cred.pV4Cred); + } else if (creds.cred_type == CC_CRED_V5) { + deep_free_cc_v5_creds (creds.cred.pV5Cred); + } +} + +/* top-level exported function */ +cc_int32 krb5int_free_cc_cred_union (cred_union** creds) +{ + if (creds == NULL) + return CC_BAD_PARM; + + if (*creds != NULL) { + deep_free_cc_creds (**creds); + free (*creds); + *creds = NULL; + } + + return CC_NOERROR; +} +#endif + /* * Utility functions... */ @@ -475,81 +950,4 @@ int stdccCredsMatch(krb5_context context, krb5_creds *base, return FALSE; } -/* ----- free_cc_cred_union, etc -------------- */ -/* - Since the Kerberos5 library allocates a credentials cache structure - (in dupK5toCC() above) with its own memory allocation routines - which - may be different than how the CCache allocates memory - the Kerb5 library - must have its own version of cc_free_creds() to deallocate it. These - functions do that. The top-level function to substitue for cc_free_creds() - is krb5_free_cc_cred_union(). - - If the CCache library wants to use a cred_union structure created by - the Kerb5 library, it should make a deep copy of it to "translate" to its - own memory allocation space. -*/ -static void deep_free_cc_data (cc_data data) -{ - if (data.data != NULL) - free (data.data); -} - -static void deep_free_cc_data_array (cc_data** data) { - - unsigned int index; - - if (data == NULL) - return; - for (index = 0; data [index] != NULL; index++) { - deep_free_cc_data (*(data [index])); - free (data [index]); - } - - free (data); -} - -static void deep_free_cc_v5_creds (cc_creds* creds) -{ - if (creds == NULL) - return; - - if (creds -> client != NULL) - free (creds -> client); - if (creds -> server != NULL) - free (creds -> server); - - deep_free_cc_data (creds -> keyblock); - deep_free_cc_data (creds -> ticket); - deep_free_cc_data (creds -> second_ticket); - - deep_free_cc_data_array (creds -> addresses); - deep_free_cc_data_array (creds -> authdata); - - free(creds); -} - -static void deep_free_cc_creds (cred_union creds) -{ - if (creds.cred_type == CC_CRED_V4) { - /* we shouldn't get this, of course */ - free (creds.cred.pV4Cred); - } else if (creds.cred_type == CC_CRED_V5) { - deep_free_cc_v5_creds (creds.cred.pV5Cred); - } -} - -/* top-level exported function */ -cc_int32 krb5_free_cc_cred_union (cred_union** creds) -{ - if (creds == NULL) - return CC_BAD_PARM; - - if (*creds != NULL) { - deep_free_cc_creds (**creds); - free (*creds); - *creds = NULL; - } - - return CC_NOERROR; -} diff --git a/src/lib/krb5/ccache/ccapi/stdcc_util.h b/src/lib/krb5/ccache/ccapi/stdcc_util.h index 92bafc8fa6..7476313dfa 100644 --- a/src/lib/krb5/ccache/ccapi/stdcc_util.h +++ b/src/lib/krb5/ccache/ccapi/stdcc_util.h @@ -5,6 +5,9 @@ #include "autoconf.h" +#if USE_CCAPI_V3 +#include +#else #if USE_CCAPI #include #endif @@ -12,17 +15,29 @@ #if defined(_WIN32) #include "cacheapi.h" #endif +#endif #include "krb5.h" /* protoypes for private functions declared in stdcc_util.c */ +#ifdef USE_CCAPI_V3 +krb5_error_code dupCC3toK5(krb5_context context, cc_credentials_t src, krb5_creds *dest); +krb5_error_code dupK5toCC3(krb5_context context, krb5_creds *src, cc_credentials_t *dest); +cc_int32 krb5int_cc_credentials_release(cc_credentials_t creds); +cc_int32 krb5int_cc_credentials_compare(cc_credentials_t creds, + cc_credentials_t compare_to, + cc_uint32* equal); +int copyCC3DataArrayToK5(cc_credentials_v5_t *ccCreds, krb5_creds *v5Creds, char whichArray); +int copyK5DataArrayToCC3(krb5_creds *v5Creds, cc_credentials_v5_t * ccCreds, char whichArray); +#else int copyCCDataArrayToK5(cc_creds *cc, krb5_creds *kc, char whichArray); int copyK5DataArrayToCC(krb5_creds *kc, cc_creds *cc, char whichArray); void dupCCtoK5(krb5_context context, cc_creds *src, krb5_creds *dest); void dupK5toCC(krb5_context context, krb5_creds *creds, cred_union **cu); +cc_int32 krb5int_free_cc_cred_union (cred_union** creds); +#endif int stdccCredsMatch(krb5_context context, krb5_creds *base, krb5_creds *match, int whichfields); int bitTst(int var, int mask); -cc_int32 krb5_free_cc_cred_union (cred_union** creds); #define kAddressArray 4 #define kAuthDataArray 5 diff --git a/src/lib/krb5/ccache/ccapi/winccld.h b/src/lib/krb5/ccache/ccapi/winccld.h index e285d1faf6..245ae245e2 100644 --- a/src/lib/krb5/ccache/ccapi/winccld.h +++ b/src/lib/krb5/ccache/ccapi/winccld.h @@ -6,12 +6,24 @@ #ifndef KRB5_WINCCLD_H_ #define KRB5_WINCCLD_H_ +#ifdef USE_CCAPI_V3 +#include +#else + #ifndef CC_API_VER2 #define CC_API_VER2 #endif #include "cacheapi.h" +#endif +#ifdef USE_CCAPI_V3 +typedef CCACHE_API cc_int32 (*FP_cc_initialize) ( + cc_context_t* outContext, + cc_int32 inVersion, + cc_int32* outSupportedVersion, + char const** outVendor); +#else typedef cc_int32 (*FP_cc_initialize)(apiCB**, const cc_int32, cc_int32*, const char**); typedef cc_int32 (*FP_cc_shutdown)(apiCB**); @@ -49,6 +61,7 @@ typedef cc_int32 (*FP_cc_seq_fetch_creds_end)(apiCB*, ccache_cit**); typedef cc_int32 (*FP_cc_free_principal)(apiCB*, char**); typedef cc_int32 (*FP_cc_free_name)(apiCB*, char** name); typedef cc_int32 (*FP_cc_free_creds)(apiCB*, cred_union** pCred); +#endif #ifdef KRB5_WINCCLD_C_ typedef struct _FUNC_INFO { @@ -64,6 +77,7 @@ typedef struct _FUNC_INFO { #endif DECL_FUNC_PTR(cc_initialize); +#ifndef USE_CCAPI_V3 DECL_FUNC_PTR(cc_shutdown); DECL_FUNC_PTR(cc_get_change_time); DECL_FUNC_PTR(cc_create); @@ -100,10 +114,12 @@ DECL_FUNC_PTR(cc_seq_fetch_creds); DECL_FUNC_PTR(cc_free_principal); DECL_FUNC_PTR(cc_free_name); DECL_FUNC_PTR(cc_free_creds); +#endif #ifdef KRB5_WINCCLD_C_ FUNC_INFO krbcc_fi[] = { MAKE_FUNC_INFO(cc_initialize), +#ifndef USE_CCAPI_V3 MAKE_FUNC_INFO(cc_shutdown), MAKE_FUNC_INFO(cc_get_change_time), MAKE_FUNC_INFO(cc_create), @@ -134,6 +150,7 @@ FUNC_INFO krbcc_fi[] = { MAKE_FUNC_INFO(cc_free_principal), MAKE_FUNC_INFO(cc_free_name), MAKE_FUNC_INFO(cc_free_creds), +#endif END_FUNC_INFO }; #undef MAKE_FUNC_INFO @@ -141,6 +158,7 @@ FUNC_INFO krbcc_fi[] = { #else #define cc_initialize pcc_initialize +#ifndef USE_CCAPI_V3 #define cc_shutdown pcc_shutdown #define cc_get_change_time pcc_get_change_time #define cc_create pcc_create @@ -178,6 +196,7 @@ FUNC_INFO krbcc_fi[] = { #define cc_free_name pcc_free_name #define cc_free_creds pcc_free_creds #endif +#endif #undef DECL_FUNC_PTR diff --git a/src/lib/krb5/ccache/ccbase.c b/src/lib/krb5/ccache/ccbase.c index 2b15ff6f32..df63e259d4 100644 --- a/src/lib/krb5/ccache/ccbase.c +++ b/src/lib/krb5/ccache/ccbase.c @@ -151,7 +151,7 @@ krb5_cc_resolve (krb5_context context, const char *name, krb5_ccache *cache) pfxlen = cp - name; - if ( pfxlen == 1 && isalpha(name[0]) ) { + if ( pfxlen == 1 && isalpha((unsigned char) name[0]) ) { /* We found a drive letter not a prefix - use FILE: */ pfx = strdup("FILE:"); if (!pfx) diff --git a/src/lib/krb5/error_tables/Makefile.in b/src/lib/krb5/error_tables/Makefile.in index df4191ff6d..323af48607 100644 --- a/src/lib/krb5/error_tables/Makefile.in +++ b/src/lib/krb5/error_tables/Makefile.in @@ -63,7 +63,7 @@ $(OUTPRE)krb524_err.$(OBJEXT): krb524_err.c clean-unix:: clean-libobjs $(RM) $(HDRS) $(ETSRCS) -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/krb5/keytab/Makefile.in b/src/lib/krb5/keytab/Makefile.in index 73b11f72a4..98e1e7981d 100644 --- a/src/lib/krb5/keytab/Makefile.in +++ b/src/lib/krb5/keytab/Makefile.in @@ -55,7 +55,7 @@ clean-windows:: $(RM) $(OBJFILE) -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/krb5/keytab/ktbase.c b/src/lib/krb5/keytab/ktbase.c index e633c0c3a7..8374e65468 100644 --- a/src/lib/krb5/keytab/ktbase.c +++ b/src/lib/krb5/keytab/ktbase.c @@ -131,7 +131,7 @@ krb5_kt_resolve (krb5_context context, const char *name, krb5_keytab *ktid) pfxlen = cp - name; - if ( pfxlen == 1 && isalpha(name[0]) ) { + if ( pfxlen == 1 && isalpha((unsigned char) name[0]) ) { /* We found a drive letter not a prefix - use FILE: */ pfx = strdup("FILE:"); if (!pfx) diff --git a/src/lib/krb5/krb/Makefile.in b/src/lib/krb5/krb/Makefile.in index edf6d5f2f1..4cbc4b9b05 100644 --- a/src/lib/krb5/krb/Makefile.in +++ b/src/lib/krb5/krb/Makefile.in @@ -360,7 +360,7 @@ clean:: $(OUTPRE)t_deltat$(EXEEXT) $(OUTPRE)t_deltat.$(OBJEXT) \ $(OUTPRE)t_expand$(EXEEXT) $(OUTPRE)t_expand.$(OBJEXT) -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/krb5/krb/conv_princ.c b/src/lib/krb5/krb/conv_princ.c index 885dc995ad..67768835f2 100644 --- a/src/lib/krb5/krb/conv_princ.c +++ b/src/lib/krb5/krb/conv_princ.c @@ -329,8 +329,8 @@ krb5_425_conv_principal(krb5_context context, const char *name, const char *inst return retval; if (domain) { for (cp = domain; *cp; cp++) - if (isupper((int) (*cp))) - *cp = tolower((int) *cp); + if (isupper((unsigned char) (*cp))) + *cp = tolower((unsigned char) *cp); strncat(buf, ".", sizeof(buf) - 1 - strlen(buf)); strncat(buf, domain, sizeof(buf) - 1 - strlen(buf)); krb5_xfree(domain); diff --git a/src/lib/krb5/krb/init_ctx.c b/src/lib/krb5/krb/init_ctx.c index e1e1e755e7..8e4ce8c3b3 100644 --- a/src/lib/krb5/krb/init_ctx.c +++ b/src/lib/krb5/krb/init_ctx.c @@ -485,3 +485,90 @@ krb5_is_permitted_enctype(krb5_context context, krb5_enctype etype) return(ret); } + +static krb5_error_code +copy_ktypes(krb5_context ctx, + unsigned int nktypes, + krb5_enctype *oldktypes, + krb5_enctype **newktypes) +{ + unsigned int i; + + *newktypes = NULL; + if (!nktypes) + return 0; + + *newktypes = malloc(nktypes * sizeof(krb5_enctype)); + if (*newktypes == NULL) + return ENOMEM; + for (i = 0; i < nktypes; i++) + (*newktypes)[i] = oldktypes[i]; + return 0; +} + +krb5_error_code KRB5_CALLCONV +krb5_copy_context(krb5_context ctx, krb5_context *nctx_out) +{ + krb5_error_code ret; + krb5_context nctx; + + *nctx_out = NULL; + if (ctx == NULL) + return EINVAL; /* XXX */ + + nctx = malloc(sizeof(*nctx)); + if (nctx == NULL) + return ENOMEM; + + *nctx = *ctx; + + nctx->in_tkt_ktypes = NULL; + nctx->in_tkt_ktype_count = 0; + nctx->tgs_ktypes = NULL; + nctx->tgs_ktype_count = 0; + nctx->default_realm = NULL; + nctx->profile = NULL; + nctx->db_context = NULL; + nctx->ser_ctx_count = 0; + nctx->ser_ctx = NULL; + nctx->prompt_types = NULL; + nctx->os_context->default_ccname = NULL; + + memset(&nctx->libkrb5_plugins, 0, sizeof(nctx->libkrb5_plugins)); + nctx->vtbl = NULL; + nctx->locate_fptrs = NULL; + + memset(&nctx->err, 0, sizeof(nctx->err)); + + ret = copy_ktypes(nctx, ctx->in_tkt_ktype_count, + ctx->in_tkt_ktypes, &nctx->in_tkt_ktypes); + if (ret) + goto errout; + nctx->in_tkt_ktype_count = ctx->in_tkt_ktype_count; + + ret = copy_ktypes(nctx, ctx->tgs_ktype_count, + ctx->tgs_ktypes, &nctx->in_tkt_ktypes); + if (ret) + goto errout; + nctx->tgs_ktype_count = ctx->tgs_ktype_count; + + if (ctx->os_context->default_ccname != NULL) { + nctx->os_context->default_ccname = + strdup(ctx->os_context->default_ccname); + if (nctx->os_context->default_ccname == NULL) { + ret = ENOMEM; + goto errout; + } + } + ret = krb5_get_profile(ctx, &nctx->profile); + if (ret) + goto errout; + +errout: + if (ret) { + krb5_free_context(nctx); + } else { + *nctx_out = nctx; + } + return ret; +} diff --git a/src/lib/krb5/krb/kerrs.c b/src/lib/krb5/krb/kerrs.c index 6de62b7806..448b38910b 100644 --- a/src/lib/krb5/krb/kerrs.c +++ b/src/lib/krb5/krb/kerrs.c @@ -28,7 +28,7 @@ #include #include "k5-int.h" -void +void KRB5_CALLCONV_C krb5_set_error_message (krb5_context ctx, krb5_error_code code, const char *fmt, ...) { @@ -40,7 +40,7 @@ krb5_set_error_message (krb5_context ctx, krb5_error_code code, va_end (args); } -void +void KRB5_CALLCONV krb5_vset_error_message (krb5_context ctx, krb5_error_code code, const char *fmt, va_list args) { @@ -49,7 +49,7 @@ krb5_vset_error_message (krb5_context ctx, krb5_error_code code, krb5int_vset_error (&ctx->err, code, fmt, args); } -char * +char * KRB5_CALLCONV krb5_get_error_message (krb5_context ctx, krb5_error_code code) { if (ctx == NULL) @@ -57,7 +57,7 @@ krb5_get_error_message (krb5_context ctx, krb5_error_code code) return krb5int_get_error (&ctx->err, code); } -void +void KRB5_CALLCONV krb5_free_error_message (krb5_context ctx, char *msg) { if (ctx == NULL) @@ -65,7 +65,7 @@ krb5_free_error_message (krb5_context ctx, char *msg) krb5int_free_error (&ctx->err, msg); } -void +void KRB5_CALLCONV krb5_clear_error_message (krb5_context ctx) { if (ctx == NULL) diff --git a/src/lib/krb5/krb/srv_rcache.c b/src/lib/krb5/krb/srv_rcache.c index 898b3f6878..da51b70b7d 100644 --- a/src/lib/krb5/krb/srv_rcache.c +++ b/src/lib/krb5/krb/srv_rcache.c @@ -115,17 +115,13 @@ krb5_get_server_rcache(krb5_context context, const krb5_data *piece, retval = krb5_rc_recover_or_initialize(context, rcache, context->clockskew); if (retval) { krb5_rc_close(context, rcache); - rcache = 0; goto cleanup; } *rcptr = rcache; - rcache = 0; retval = 0; cleanup: - if (rcache) - krb5_xfree(rcache); if (cachename) krb5_xfree(cachename); return retval; diff --git a/src/lib/krb5/libkrb5.exports b/src/lib/krb5/libkrb5.exports index b2fd14e575..94e94e45db 100644 --- a/src/lib/krb5/libkrb5.exports +++ b/src/lib/krb5/libkrb5.exports @@ -323,6 +323,7 @@ krb5_copy_addresses krb5_copy_authdata krb5_copy_authenticator krb5_copy_checksum +krb5_copy_context krb5_copy_creds krb5_copy_data krb5_copy_keyblock diff --git a/src/lib/krb5/os/Makefile.in b/src/lib/krb5/os/Makefile.in index db391ab15f..6f74ad61a4 100644 --- a/src/lib/krb5/os/Makefile.in +++ b/src/lib/krb5/os/Makefile.in @@ -7,6 +7,7 @@ PROG_LIBPATH=-L$(TOPLIBD) PROG_RPATH=$(KRB5_LIBDIR) DEFS= DEFINES=-DLIBDIR=\"$(KRB5_LIBDIR)\" +LOCALINCLUDES=-I$(SRCTOP)/util/profile ##DOS##BUILDTOP = ..\..\.. ##DOS##PREFIXDIR=os @@ -161,8 +162,7 @@ shared: TEST_PROGS= t_std_conf t_an_to_ln t_locate_kdc -T_STD_CONF_OBJS= t_std_conf.o def_realm.o get_krbhst.o realm_dom.o \ - hst_realm.o init_os_ctx.o locate_kdc.o dnsglue.o +T_STD_CONF_OBJS= t_std_conf.o T_AN_TO_LN_OBJS = t_an_to_ln.o an_to_ln.o @@ -239,7 +239,7 @@ check-unix:: clean:: $(RM) $(TEST_PROGS) test.out t_std_conf.o t_an_to_ln.o -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # @@ -392,7 +392,8 @@ init_os_ctx.so init_os_ctx.po $(OUTPRE)init_os_ctx.$(OBJEXT): \ $(SRCTOP)/include/k5-platform.h $(SRCTOP)/include/k5-plugin.h \ $(SRCTOP)/include/k5-thread.h $(SRCTOP)/include/krb5.h \ $(SRCTOP)/include/krb5/locate_plugin.h $(SRCTOP)/include/port-sockets.h \ - $(SRCTOP)/include/socket-utils.h init_os_ctx.c os-proto.h + $(SRCTOP)/include/socket-utils.h $(SRCTOP)/util/profile/prof_int.h \ + init_os_ctx.c os-proto.h krbfileio.so krbfileio.po $(OUTPRE)krbfileio.$(OBJEXT): \ $(BUILDTOP)/include/autoconf.h $(BUILDTOP)/include/krb5/krb5.h \ $(BUILDTOP)/include/osconf.h $(BUILDTOP)/include/profile.h \ diff --git a/src/lib/krb5/os/hst_realm.c b/src/lib/krb5/os/hst_realm.c index b5c8f66ff4..17b1e42c49 100644 --- a/src/lib/krb5/os/hst_realm.c +++ b/src/lib/krb5/os/hst_realm.c @@ -235,8 +235,8 @@ krb5_get_host_realm(krb5_context context, const char *host, char ***realmsp) } for (cp = local_host; *cp; cp++) { - if (isupper((int) (*cp))) - *cp = tolower((int) *cp); + if (isupper((unsigned char) (*cp))) + *cp = tolower((unsigned char) *cp); } l = strlen(local_host); /* strip off trailing dot */ @@ -318,8 +318,8 @@ krb5_get_host_realm(krb5_context context, const char *host, char ***realmsp) /* Assume the realm name is upper case */ for (cp = realm; *cp; cp++) - if (islower((int) (*cp))) - *cp = toupper((int) *cp); + if (islower((unsigned char) (*cp))) + *cp = toupper((unsigned char) *cp); } else { /* We are defaulting to the local realm */ retval = krb5_get_default_realm(context, &realm); diff --git a/src/lib/krb5/os/init_os_ctx.c b/src/lib/krb5/os/init_os_ctx.c index d26743ac69..893355ef93 100644 --- a/src/lib/krb5/os/init_os_ctx.c +++ b/src/lib/krb5/os/init_os_ctx.c @@ -30,6 +30,7 @@ #include "k5-int.h" #include "os-proto.h" +#include "prof_int.h" /* XXX for profile_copy, not public yet */ #ifdef USE_LOGIN_LIBRARY #include "KerberosLoginPrivate.h" @@ -414,30 +415,7 @@ krb5_os_init_context(krb5_context ctx, krb5_boolean kdc) krb5_error_code KRB5_CALLCONV krb5_get_profile (krb5_context ctx, profile_t *profile) { - krb5_error_code retval = 0; - profile_filespec_t *files = 0; - - retval = os_get_default_config_files(&files, ctx->profile_secure); - - if (!retval) { - retval = profile_init((const_profile_filespec_t *) files, - profile); - } - - if (files) - free_filespecs(files); - - if (retval == ENOENT) - return KRB5_CONFIG_CANTOPEN; - - if ((retval == PROF_SECTION_NOTOP) || - (retval == PROF_SECTION_SYNTAX) || - (retval == PROF_RELATION_SYNTAX) || - (retval == PROF_EXTRA_CBRACE) || - (retval == PROF_MISSING_OBRACE)) - return KRB5_CONFIG_BADFORMAT; - - return retval; + return profile_copy (ctx->profile, profile); } diff --git a/src/lib/krb5/os/sn2princ.c b/src/lib/krb5/os/sn2princ.c index 65678c8294..2ba7e8ae2a 100644 --- a/src/lib/krb5/os/sn2princ.c +++ b/src/lib/krb5/os/sn2princ.c @@ -148,8 +148,8 @@ krb5_sname_to_principal(krb5_context context, const char *hostname, const char * if (type == KRB5_NT_SRV_HST) for (cp = remote_host; *cp; cp++) - if (isupper((int) (*cp))) - *cp = tolower((int) (*cp)); + if (isupper((unsigned char) (*cp))) + *cp = tolower((unsigned char) (*cp)); /* * Windows NT5's broken resolver gratuitously tacks on a diff --git a/src/lib/krb5/posix/Makefile.in b/src/lib/krb5/posix/Makefile.in index 64a0773276..65a7b601d5 100644 --- a/src/lib/krb5/posix/Makefile.in +++ b/src/lib/krb5/posix/Makefile.in @@ -15,4 +15,4 @@ all-unix:: all-libobjs clean-unix:: clean-libobjs ##WIN32##LIBOBJS = $(OUTPRE)syslog.obj -# @libobj_frag@ +@libobj_frag@ diff --git a/src/lib/krb5/rcache/Makefile.in b/src/lib/krb5/rcache/Makefile.in index 05b7609558..5ade489007 100644 --- a/src/lib/krb5/rcache/Makefile.in +++ b/src/lib/krb5/rcache/Makefile.in @@ -43,7 +43,7 @@ SRCS= \ all-unix:: all-libobjs clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/lib/krb5_32.def b/src/lib/krb5_32.def index db0be8c617..9785df5630 100644 --- a/src/lib/krb5_32.def +++ b/src/lib/krb5_32.def @@ -100,6 +100,7 @@ krb5_c_string_to_key_with_params krb5_copy_authdata krb5_copy_authenticator krb5_copy_checksum + krb5_copy_context krb5_copy_creds krb5_copy_data krb5_copy_keyblock diff --git a/src/lib/rpc/Makefile.in b/src/lib/rpc/Makefile.in index 1d3c6eacbf..1e28cc22c9 100644 --- a/src/lib/rpc/Makefile.in +++ b/src/lib/rpc/Makefile.in @@ -280,8 +280,8 @@ clean-windows:: $(HDRS): includes -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/patchlevel.h b/src/patchlevel.h index 1a7bc741b6..79a29ccf4f 100644 --- a/src/patchlevel.h +++ b/src/patchlevel.h @@ -1,7 +1,7 @@ /* * patchlevel.h * - * Copyright (C) 2004 by the Massachusetts Institute of Technology. + * Copyright (C) 2004-2006 by the Massachusetts Institute of Technology. * All rights reserved. * * Export of this software from the United States of America may @@ -51,8 +51,8 @@ * organization. */ #define KRB5_MAJOR_RELEASE 1 -#define KRB5_MINOR_RELEASE 5 +#define KRB5_MINOR_RELEASE 6 #define KRB5_PATCHLEVEL 0 -#define KRB5_RELTAIL "alpha1-postrelease" +#define KRB5_RELTAIL "prerelease" /* #undef KRB5_RELDATE */ /* #undef KRB5_RELTAG */ diff --git a/src/plugins/kdb/db2/Makefile.in b/src/plugins/kdb/db2/Makefile.in index bf1a6c05e6..d790637018 100644 --- a/src/plugins/kdb/db2/Makefile.in +++ b/src/plugins/kdb/db2/Makefile.in @@ -76,8 +76,8 @@ $(DB_DEPS) $(DBOBJLISTS-k5) $(DBSHOBJLISTS): all-recurse clean:: $(RM) lib$(LIBBASE)$(SO_EXT) db2_exp.o -# @libnover_frag@ -# @libobj_frag@ +@libnover_frag@ +@libobj_frag@ .depend-verify-db: depend-verify-db-$(DB_VERSION) depend-verify-db-k5: diff --git a/src/plugins/kdb/db2/libdb2/Makefile.in b/src/plugins/kdb/db2/libdb2/Makefile.in index 93fed6f3c0..1d977ed868 100644 --- a/src/plugins/kdb/db2/libdb2/Makefile.in +++ b/src/plugins/kdb/db2/libdb2/Makefile.in @@ -40,4 +40,4 @@ $(srcdir)/include/autoconf.stmp: $(srcdir)/configure.in $(SRCTOP)/aclocal.m4 clean-includes:: $(RM) $(HDRS) include/*.stmp -# @lib_frag@ +@lib_frag@ diff --git a/src/plugins/kdb/db2/libdb2/btree/Makefile.in b/src/plugins/kdb/db2/libdb2/btree/Makefile.in index 52243b4607..eb166d37b3 100644 --- a/src/plugins/kdb/db2/libdb2/btree/Makefile.in +++ b/src/plugins/kdb/db2/libdb2/btree/Makefile.in @@ -11,4 +11,4 @@ LOCALINCLUDES= -I. -I$(srcdir)/../include -I../include -I$(srcdir)/../mpool \ all-unix:: all-libobjs clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ diff --git a/src/plugins/kdb/db2/libdb2/clib/Makefile.in b/src/plugins/kdb/db2/libdb2/clib/Makefile.in index 09f8089672..8ea1ec8d63 100644 --- a/src/plugins/kdb/db2/libdb2/clib/Makefile.in +++ b/src/plugins/kdb/db2/libdb2/clib/Makefile.in @@ -8,4 +8,4 @@ LOCALINCLUDES=-I../include all-unix:: all-libobjs clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ diff --git a/src/plugins/kdb/db2/libdb2/db/Makefile.in b/src/plugins/kdb/db2/libdb2/db/Makefile.in index 074bb7f329..e40c69186f 100644 --- a/src/plugins/kdb/db2/libdb2/db/Makefile.in +++ b/src/plugins/kdb/db2/libdb2/db/Makefile.in @@ -8,4 +8,4 @@ LOCALINCLUDES= -I. -I$(srcdir)/../include -I../include -I$(srcdir)/../mpool all-unix:: all-libobjs clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ diff --git a/src/plugins/kdb/db2/libdb2/hash/Makefile.in b/src/plugins/kdb/db2/libdb2/hash/Makefile.in index 1e60e9a18c..232376012b 100644 --- a/src/plugins/kdb/db2/libdb2/hash/Makefile.in +++ b/src/plugins/kdb/db2/libdb2/hash/Makefile.in @@ -10,4 +10,4 @@ LOCALINCLUDES= -I. -I$(srcdir)/../include -I../include -I$(srcdir)/../mpool \ all-unix:: all-libobjs clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ diff --git a/src/plugins/kdb/db2/libdb2/mpool/Makefile.in b/src/plugins/kdb/db2/libdb2/mpool/Makefile.in index 9745c4e300..d06b69a9c2 100644 --- a/src/plugins/kdb/db2/libdb2/mpool/Makefile.in +++ b/src/plugins/kdb/db2/libdb2/mpool/Makefile.in @@ -8,4 +8,4 @@ LOCALINCLUDES= -I. -I$(srcdir)/../include -I../include -I$(srcdir)/../db all-unix:: all-libobjs clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ diff --git a/src/plugins/kdb/db2/libdb2/recno/Makefile.in b/src/plugins/kdb/db2/libdb2/recno/Makefile.in index 4d6b9a5084..ba0697cb80 100644 --- a/src/plugins/kdb/db2/libdb2/recno/Makefile.in +++ b/src/plugins/kdb/db2/libdb2/recno/Makefile.in @@ -10,4 +10,4 @@ LOCALINCLUDES= -I. -I$(srcdir)/../include -I../include -I$(srcdir)/../mpool \ all-unix:: all-libobjs clean-unix:: clean-libobjs -# @libobj_frag@ +@libobj_frag@ diff --git a/src/plugins/locate/python/Makefile.in b/src/plugins/locate/python/Makefile.in index fc8009c8f6..9915052aa8 100644 --- a/src/plugins/locate/python/Makefile.in +++ b/src/plugins/locate/python/Makefile.in @@ -25,8 +25,8 @@ all-unix:: $(LIBBASE)$(SO_EXT) install-unix:: install-libs clean-unix:: clean-libs clean-libobjs -# @libnover_frag@ -# @libobj_frag@ +@libnover_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/slave/kpropd.M b/src/slave/kpropd.M index 98035fcf95..1d53b101b1 100644 --- a/src/slave/kpropd.M +++ b/src/slave/kpropd.M @@ -119,11 +119,19 @@ allow for an alternate port number for .I kpropd to listen on. This is only useful if the program is run in standalone mode. +.TP +.B \-a +allows the user to specify the path to the +.KR kpropd.acl +file; by default the path used is KPROPD_ACL_FILE +(normally /usr/local/var/krb5kdc/kpropd.acl). .SH FILES .TP "\w'kpropd.acl\ \ 'u" kpropd.acl Access file for -.BR kpropd . +.BR kpropd ; +the default location is KPROPD_ACL_FILE (normally +/usr/local/var/krb5kdc/kpropd.acl). Each entry is a line containing the principal of a host from which the local machine will allow Kerberos database propagation via kprop. .SH SEE ALSO diff --git a/src/slave/kpropd.c b/src/slave/kpropd.c index 9d87b9ebf5..77c2703917 100644 --- a/src/slave/kpropd.c +++ b/src/slave/kpropd.c @@ -478,7 +478,7 @@ void PRS(argv) case 'S': standalone++; break; - case 'a': + case 'a': if (*word) acl_file_name = word; else diff --git a/src/tests/asn.1/utility.c b/src/tests/asn.1/utility.c index 660161fa19..6ad2e9de85 100644 --- a/src/tests/asn.1/utility.c +++ b/src/tests/asn.1/utility.c @@ -77,9 +77,9 @@ krb5_error_code krb5_data_hex_parse(krb5_data *d, const char *s) for (lo = 0, dp = d->data, cp = s; *cp; cp++) { if (*cp < 0) return ASN1_PARSE_ERROR; - else if (isspace(*cp)) + else if (isspace((unsigned char) *cp)) continue; - else if (isxdigit(*cp)) { + else if (isxdigit((unsigned char) *cp)) { buf[0] = *cp; v = strtol(buf, NULL, 16); } else diff --git a/src/tests/dejagnu/krb-standalone/gssftp.exp b/src/tests/dejagnu/krb-standalone/gssftp.exp index 8d78c58c81..b9284fcc47 100644 --- a/src/tests/dejagnu/krb-standalone/gssftp.exp +++ b/src/tests/dejagnu/krb-standalone/gssftp.exp @@ -198,7 +198,7 @@ proc ftp_test { } { start_ftp_daemon # Make an ftp client connection to it. - spawn $FTP $hostname [expr 8 + $portbase] + spawn $FTP -d -v $hostname [expr 8 + $portbase] expect_after { "GSSAPI authentication failed" { diff --git a/src/tests/dejagnu/krb-standalone/standalone.exp b/src/tests/dejagnu/krb-standalone/standalone.exp index dbe9b950c4..554906e446 100644 --- a/src/tests/dejagnu/krb-standalone/standalone.exp +++ b/src/tests/dejagnu/krb-standalone/standalone.exp @@ -31,6 +31,8 @@ proc doit { } { global spawn_id global supported_enctypes global KRBIV + global portbase + global mode # Start up the kerberos and kadmind daemons. if ![start_kerberos_daemons 1] { @@ -143,6 +145,36 @@ proc doit { } { pass "kadmin.local correct high kvno" } } + + if { $mode == "tcp" } { + set response {} + set got_response 0 + set kdcsock "" + catch { + send_log "connecting to $hostname [expr 3 + $portbase]\n" + set kdcsock [socket $hostname [expr 3 + $portbase]] + fconfigure $kdcsock -encoding binary -blocking 0 -buffering none + puts -nonewline $kdcsock [binary format H* ffffffff] + # XXX + sleep 3 + set response [read $kdcsock] + set got_response 1 + } msg + if [string length $kdcsock] { catch "close $kdcsock" } + if $got_response { +# send_log [list sent length -1, got back $response] +# send_log "\n" + if [string length $response]>10 { + pass "too-long TCP request" + } else { + send_log "response too short\n" + fail "too-long TCP request" + } + } else { + send_log "too-long connect/exchange failure: $msg\n" + fail "too-long TCP request" + } + } } set status [catch doit msg] diff --git a/src/util/def-check.pl b/src/util/def-check.pl index 447421e8e7..b007c9cecd 100644 --- a/src/util/def-check.pl +++ b/src/util/def-check.pl @@ -9,7 +9,10 @@ eval 'exec /usr/athena/bin/perl -S $0 ${1+"$@"}' use strict; use IO::File; -my $h_filename = shift @ARGV || die "usage: $0 header-file [def-file]\n"; +my $verbose = 0; +my $error = 0; +if ( $ARGV[0] eq "-v" ) { $verbose = 1; shift @ARGV; } +my $h_filename = shift @ARGV || die "usage: $0 [-v] header-file [def-file]\n"; my $d_filename = shift @ARGV; my $h = open_always($h_filename); @@ -47,14 +50,12 @@ while (! $h->eof()) { } Top: # drop KRB5INT_BEGIN_DECLS and KRB5INT_END_DECLS - if (/^ *KRB5INT_BEGIN_DECLS/) { - next LINE; - } - if (/^ *KRB5INT_END_DECLS/) { + if (/^ *(KRB5INT|GSSAPI[A-Z]*)_(BEGIN|END)_DECLS/) { next LINE; } # drop preprocessor directives if (/^ *#/) { + while (/\\$/) { $_ .= $h->getline(); } next LINE; } if (/^ *\?==/) { @@ -75,7 +76,7 @@ while (! $h->eof()) { } # multi-line comments? if (/\/\*$/) { - $_ .= "\n"; + $_ .= " "; $len1 = length; $_ .= $h->getline(); chop if $len1 < length; @@ -85,7 +86,7 @@ while (! $h->eof()) { if (/^[ \t]*$/) { next LINE; } - if (/ *extern "C" {/) { + if (/^ *extern "C" {/) { next LINE; } # elide struct definitions @@ -180,11 +181,13 @@ while (! $h->eof()) { } } -print join("\n\t", "Using default calling convention:", sort(@convD)); -print join("\n\t", "\nUsing KRB5_CALLCONV:", sort(@convK)); -print join("\n\t", "\nUsing KRB5_CALLCONV_C:", sort(@convC)); -print join("\n\t", "\nUsing KRB5_CALLCONV_WRONG:", sort(@convW)); -print "\n","-"x70,"\n"; +if ( $verbose ) { + print join("\n\t", "Using default calling convention:", sort(@convD)); + print join("\n\t", "\nUsing KRB5_CALLCONV:", sort(@convK)); + print join("\n\t", "\nUsing KRB5_CALLCONV_C:", sort(@convC)); + print join("\n\t", "\nUsing KRB5_CALLCONV_WRONG:", sort(@convW)); + print "\n","-"x70,"\n"; +} %conv = (); map { $conv{$_} = "default"; } @convD; @@ -196,8 +199,8 @@ my %vararg = (); map { $vararg{$_} = 1; } @vararg; if (!$d) { - print "No .DEF file specified\n"; - exit; + print "No .DEF file specified\n" if $verbose; + exit 0; } LINE2: @@ -213,7 +216,7 @@ while (! $d->eof()) { $printit = 0; next LINE2; } - if (/^EXPORTS/) { + if (/^EXPORTS/ || /^DESCRIPTION/ || /^HEAPSIZE/) { $printit = 0; next LINE2; } @@ -221,6 +224,8 @@ while (! $d->eof()) { my($xconv); if (/PRIVATE/ || /INTERNAL/) { $xconv = "PRIVATE"; + } elsif (/DATA/) { + $xconv = "DATA"; } elsif (/!CALLCONV/ || /KRB5_CALLCONV_WRONG/) { $xconv = "KRB5_CALLCONV_WRONG"; } elsif ($vararg{$_}) { @@ -231,16 +236,23 @@ while (! $d->eof()) { s/;.*$//; if ($xconv eq "PRIVATE") { - print "\t private $_\n"; + print "\t private $_\n" if $verbose; + next LINE2; + } + if ($xconv eq "DATA") { + print "\t data $_\n" if $verbose; next LINE2; } if (!defined($conv{$_})) { print "No calling convention specified for $_!\n"; + $error = 1; } elsif (! ($conv{$_} eq $xconv)) { print "Function $_ should have calling convention '$xconv', but has '$conv{$_}' instead.\n"; + $error = 1; } else { # print "Function $_ is okay.\n"; } } #print "Calling conventions defined for: ", keys(%conv); +exit $error; diff --git a/src/util/et/Makefile.in b/src/util/et/Makefile.in index 184ca50fb0..fd31129637 100644 --- a/src/util/et/Makefile.in +++ b/src/util/et/Makefile.in @@ -245,8 +245,8 @@ TAGS: et_name.c error_message.c compile_et.c error_table.c \ depend:: et_lex.lex.c -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/util/mkrel b/src/util/mkrel index 51d47afc92..2384b7dee0 100755 --- a/src/util/mkrel +++ b/src/util/mkrel @@ -139,22 +139,6 @@ if test $checkout = t; then svn export $repository/$reltag $reldir fi -if test $dosrc = t; then - if test -d $reldir/src/util/autoconf; then - echo "Building autoconf..." - (cd $reldir/src/util/autoconf - M4=gm4 ./configure - make) - fi - echo "Creating configure scripts..." - (cd $reldir/src; util/reconf) - - if test -d $reldir/src/util/autoconf; then - echo "Cleaning src/util/autoconf..." - (cd $reldir/src/util/autoconf; make distclean) - fi -fi - echo "Editing release-specific files..." if test $newstyle = t; then @@ -162,6 +146,9 @@ if test $newstyle = t; then sed -e '/RELDATE/c\ #define KRB5_RELDATE "'"$reldate"'"' patchlevel.h > patchlevel.h.new && \ mv patchlevel.h.new patchlevel.h) + if test $checkout = t; then + (cd $reldir && svn log -v $repository/$reltag > doc/CHANGES) + fi else (cd $reldir/src/lib/krb5/krb && \ @@ -182,6 +169,22 @@ EOF ) fi +if test $dosrc = t; then + if test -d $reldir/src/util/autoconf; then + echo "Building autoconf..." + (cd $reldir/src/util/autoconf + M4=gm4 ./configure + make) + fi + echo "Creating configure scripts..." + (cd $reldir/src; util/reconf) + + if test -d $reldir/src/util/autoconf; then + echo "Cleaning src/util/autoconf..." + (cd $reldir/src/util/autoconf; make distclean) + fi +fi + echo "Nuking unneeded files..." find $reldir \( -name TODO -o -name todo -o -name .cvsignore \ -o -name BADSYMS -o -name .Sanitize -o -name .rconf \) -print \ diff --git a/src/util/profile/Makefile.in b/src/util/profile/Makefile.in index 1175a3ef10..3d99ea70ef 100644 --- a/src/util/profile/Makefile.in +++ b/src/util/profile/Makefile.in @@ -151,8 +151,8 @@ check-windows:: $(OUTPRE)test_profile.exe $(OUTPRE)test_parse.exe $(OUTPRE)test_parse test.ini -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/util/profile/prof_init.c b/src/util/profile/prof_init.c index 888d46d0a6..e5c6f9c8c5 100644 --- a/src/util/profile/prof_init.c +++ b/src/util/profile/prof_init.c @@ -66,6 +66,39 @@ profile_init(const_profile_filespec_t *files, profile_t *ret_profile) return 0; } +#define COUNT_LINKED_LIST(COUNT, PTYPE, START, FIELD) \ + { \ + int cll_counter = 0; \ + PTYPE cll_ptr = (START); \ + while (cll_ptr != NULL) { \ + cll_counter++; \ + cll_ptr = cll_ptr->FIELD; \ + } \ + (COUNT) = cll_counter; \ + } + +errcode_t KRB5_CALLCONV +profile_copy(profile_t old_profile, profile_t *new_profile) +{ + size_t size, i; + const_profile_filespec_t *files; + prf_file_t file; + errcode_t err; + + /* The fields we care about are read-only after creation, so + no locking is needed. */ + COUNT_LINKED_LIST (size, prf_file_t, old_profile->first_file, next); + files = malloc ((size+1) * sizeof(*files)); + if (files == NULL) + return errno; + for (i = 0, file = old_profile->first_file; i < size; i++, file = file->next) + files[i] = file->data->filespec; + files[size] = NULL; + err = profile_init (files, new_profile); + free (files); + return err; +} + errcode_t KRB5_CALLCONV profile_init_path(const_profile_filespec_list_t filepath, profile_t *ret_profile) diff --git a/src/util/profile/prof_int.h b/src/util/profile/prof_int.h index 70a8dd9208..d6349afd72 100644 --- a/src/util/profile/prof_int.h +++ b/src/util/profile/prof_int.h @@ -192,6 +192,8 @@ errcode_t profile_rename_node /* prof_file.c */ +errcode_t KRB5_CALLCONV profile_copy (profile_t, profile_t *); + errcode_t profile_open_file (const_profile_filespec_t file, prf_file_t *ret_prof); diff --git a/src/util/ss/Makefile.in b/src/util/ss/Makefile.in index b9a492a868..fe39c39183 100644 --- a/src/util/ss/Makefile.in +++ b/src/util/ss/Makefile.in @@ -166,8 +166,8 @@ clean:: TAGS test_ss -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/util/support/Makefile.in b/src/util/support/Makefile.in index 4b0ea81bb6..a6aa3fccf4 100644 --- a/src/util/support/Makefile.in +++ b/src/util/support/Makefile.in @@ -19,8 +19,8 @@ PROG_LIBPATH=-L$(TOPLIBD) PROG_RPATH=$(KRB5_LIBDIR) LIBBASE=krb5support -LIBMAJOR=1 -LIBMINOR=0 +LIBMAJOR=@SUPPORTLIB_MAJOR@ +LIBMINOR=1 LIBINITFUNC=krb5int_thread_support_init LIBFINIFUNC=krb5int_thread_support_fini @@ -76,8 +76,8 @@ $(BUILDTOP)/include/autoconf.h: $(SRCTOP)/include/autoconf.h.in t_mktime: gmt_mktime.c $(CC) $(ALL_CFLAGS) -DTEST_LEAP -o t_mktime $(srcdir)/gmt_mktime.c -# @lib_frag@ -# @libobj_frag@ +@lib_frag@ +@libobj_frag@ # +++ Dependency line eater +++ # diff --git a/src/util/support/errors.c b/src/util/support/errors.c index 67ddf625c6..7c93753d47 100644 --- a/src/util/support/errors.c +++ b/src/util/support/errors.c @@ -48,6 +48,8 @@ void krb5int_vset_error (struct errinfo *ep, long code, const char *fmt, va_list args) { + char *p; + if (ep->msg && ep->msg != ep->scratch_buf) { free (ep->msg); ep->msg = NULL; @@ -63,18 +65,20 @@ krb5int_vset_error (struct errinfo *ep, long code, } #endif vsnprintf(ep->scratch_buf, sizeof(ep->scratch_buf), fmt, args); - ep->msg = ep->scratch_buf; + p = strdup(ep->scratch_buf); + ep->msg = p ? p : ep->scratch_buf; } char * krb5int_get_error (struct errinfo *ep, long code) { char *r, *r2; - if (code != ep->code) - krb5int_clear_error (ep); - if (ep->msg) { - r = ep->msg; - ep->msg = NULL; + if (code == ep->code && ep->msg) { + r = strdup(ep->msg); + if (r == NULL) { + strcpy(ep->scratch_buf, _("Out of memory")); + r = ep->scratch_buf; + } return r; } if (initialize() != 0) { @@ -88,8 +92,12 @@ krb5int_get_error (struct errinfo *ep, long code) if (fptr == NULL) { unlock(); #ifdef HAVE_STRERROR_R - if (strerror_r (code, ep->scratch_buf, sizeof(ep->scratch_buf)) == 0) + if (strerror_r (code, ep->scratch_buf, sizeof(ep->scratch_buf)) == 0) { + char *p = strdup(ep->scratch_buf); + if (p) + return p; return ep->scratch_buf; + } /* If strerror_r didn't work with the 1K buffer, we can try a really big one. This seems kind of gratuitous though. */ #define BIG_ERR_BUFSIZ 8192 diff --git a/src/util/support/fake-addrinfo.c b/src/util/support/fake-addrinfo.c index 922dc8d9b1..eba4c74b60 100644 --- a/src/util/support/fake-addrinfo.c +++ b/src/util/support/fake-addrinfo.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2001,2002,2003,2004,2005 by the Massachusetts Institute of Technology, + * Copyright (C) 2001,2002,2003,2004,2005,2006 by the Massachusetts Institute of Technology, * Cambridge, MA, USA. All Rights Reserved. * * This software is being provided to you, the LICENSEE, by the @@ -162,20 +162,23 @@ extern /*@dependent@*/ char *gai_strerror (int code) /*@*/; either getaddrinfo or one of these two flavors of gethostbyname_r? */ #if !defined(HAVE_GETHOSTBYNAME_R) || defined(THREADSAFE_GETHOSTBYNAME) -#define GET_HOST_BY_NAME(NAME, HP, ERR) \ - { (HP) = gethostbyname (NAME); (ERR) = h_errno; } -#define GET_HOST_BY_ADDR(ADDR, ADDRLEN, FAMILY, HP, ERR) \ - { (HP) = gethostbyaddr ((ADDR), (ADDRLEN), (FAMILY)); (ERR) = h_errno; } +typedef struct hostent *GET_HOST_TMP; +#define GET_HOST_BY_NAME(NAME, HP, ERR, TMP) \ + { TMP = gethostbyname (NAME); (ERR) = h_errno; (HP) = TMP; } +#define GET_HOST_BY_ADDR(ADDR, ADDRLEN, FAMILY, HP, ERR, TMP) \ + { TMP = gethostbyaddr ((ADDR), (ADDRLEN), (FAMILY)); (ERR) = h_errno; (HP) = TMP; } #else #ifdef _AIX /* XXX should have a feature test! */ -#define GET_HOST_BY_NAME(NAME, HP, ERR) \ - { \ - struct hostent my_h_ent; \ - struct hostent_data my_h_ent_data; \ - (HP) = (gethostbyname_r((NAME), &my_h_ent, &my_h_ent_data) \ - ? 0 \ - : &my_h_ent); \ - (ERR) = h_errno; \ +typedef struct { + struct hostent ent; + struct hostent_data data; +} GET_HOST_TMP; +#define GET_HOST_BY_NAME(NAME, HP, ERR, TMP) \ + { \ + (HP) = (gethostbyname_r((NAME), &TMP.ent, &TMP.data) \ + ? 0 \ + : &my_h_ent); \ + (ERR) = h_errno; \ } /* #define GET_HOST_BY_ADDR(ADDR, ADDRLEN, FAMILY, HP, ERR) \ @@ -191,47 +194,51 @@ extern /*@dependent@*/ char *gai_strerror (int code) /*@*/; */ #else #ifdef GETHOSTBYNAME_R_RETURNS_INT -#define GET_HOST_BY_NAME(NAME, HP, ERR) \ +typedef struct { + struct hostent ent; + char buf[8192]; +} GET_HOST_TMP; +#define GET_HOST_BY_NAME(NAME, HP, ERR, TMP) \ { \ - struct hostent my_h_ent, *my_hp; \ - int my_h_err; \ - char my_h_buf[8192]; \ - (HP) = (gethostbyname_r((NAME), &my_h_ent, \ - my_h_buf, sizeof (my_h_buf), &my_hp, \ - &my_h_err) \ + struct hostent *my_hp = NULL; \ + int my_h_err, my_ret; \ + my_ret = gethostbyname_r((NAME), &TMP.ent, \ + TMP.buf, sizeof (TMP.buf), &my_hp, \ + &my_h_err); \ + (HP) = (((my_ret != 0) || (my_hp != &TMP.ent)) \ ? 0 \ - : &my_h_ent); \ + : &TMP.ent); \ (ERR) = my_h_err; \ } -#define GET_HOST_BY_ADDR(ADDR, ADDRLEN, FAMILY, HP, ERR) \ +#define GET_HOST_BY_ADDR(ADDR, ADDRLEN, FAMILY, HP, ERR, TMP) \ { \ - struct hostent my_h_ent, *my_hp; \ - int my_h_err; \ - char my_h_buf[8192]; \ - (HP) = (gethostbyaddr_r((ADDR), (ADDRLEN), (FAMILY), &my_h_ent, \ - my_h_buf, sizeof (my_h_buf), &my_hp, \ - &my_h_err) \ + struct hostent *my_hp; \ + int my_h_err, my_ret; \ + my_ret = gethostbyaddr_r((ADDR), (ADDRLEN), (FAMILY), &TMP.ent, \ + TMP.buf, sizeof (TMP.buf), &my_hp, \ + &my_h_err); \ + (HP) = (((my_ret != 0) || (my_hp != &TMP.ent)) \ ? 0 \ - : &my_h_ent); \ + : &TMP.ent); \ (ERR) = my_h_err; \ } #else -#define GET_HOST_BY_NAME(NAME, HP, ERR) \ +typedef struct { + struct hostent ent; + char buf[8192]; +} GET_HOST_TMP; +#define GET_HOST_BY_NAME(NAME, HP, ERR, TMP) \ { \ - struct hostent my_h_ent; \ int my_h_err; \ - char my_h_buf[8192]; \ - (HP) = gethostbyname_r((NAME), &my_h_ent, \ - my_h_buf, sizeof (my_h_buf), &my_h_err); \ + (HP) = gethostbyname_r((NAME), &TMP.ent, \ + TMP.buf, sizeof (TMP.buf), &my_h_err); \ (ERR) = my_h_err; \ } -#define GET_HOST_BY_ADDR(ADDR, ADDRLEN, FAMILY, HP, ERR) \ +#define GET_HOST_BY_ADDR(ADDR, ADDRLEN, FAMILY, HP, ERR, TMP) \ { \ - struct hostent my_h_ent; \ int my_h_err; \ - char my_h_buf[8192]; \ - (HP) = gethostbyaddr_r((ADDR), (ADDRLEN), (FAMILY), &my_h_ent, \ - my_h_buf, sizeof (my_h_buf), &my_h_err); \ + (HP) = gethostbyaddr_r((ADDR), (ADDRLEN), (FAMILY), &TMP.ent, \ + TMP.buf, sizeof (TMP.buf), &my_h_err); \ (ERR) = my_h_err; \ } #endif /* returns int? */ @@ -240,53 +247,57 @@ extern /*@dependent@*/ char *gai_strerror (int code) /*@*/; /* Now do the same for getservby* functions. */ #ifndef HAVE_GETSERVBYNAME_R -#define GET_SERV_BY_NAME(NAME, PROTO, SP, ERR) \ - ((SP) = getservbyname (NAME, PROTO), (ERR) = (SP) ? 0 : -1) -#define GET_SERV_BY_PORT(PORT, PROTO, SP, ERR) \ - ((SP) = getservbyport (PORT, PROTO), (ERR) = (SP) ? 0 : -1) +typedef struct servent *GET_SERV_TMP; +#define GET_SERV_BY_NAME(NAME, PROTO, SP, ERR, TMP) \ + (TMP = getservbyname (NAME, PROTO), (SP) = TMP, (ERR) = (SP) ? 0 : -1) +#define GET_SERV_BY_PORT(PORT, PROTO, SP, ERR, TMP) \ + (TMP = getservbyport (PORT, PROTO), (SP) = TMP, (ERR) = (SP) ? 0 : -1) #else #ifdef GETSERVBYNAME_R_RETURNS_INT -#define GET_SERV_BY_NAME(NAME, PROTO, SP, ERR) \ +typedef struct { + struct servent ent; + char buf[8192]; +} GET_SERV_TMP; +#define GET_SERV_BY_NAME(NAME, PROTO, SP, ERR, TMP) \ { \ - struct servent my_s_ent, *my_sp; \ + struct servent *my_sp; \ int my_s_err; \ - char my_s_buf[8192]; \ - (SP) = (getservbyname_r((NAME), (PROTO), &my_s_ent, \ - my_s_buf, sizeof (my_s_buf), &my_sp, \ + (SP) = (getservbyname_r((NAME), (PROTO), &TMP.ent, \ + TMP.buf, sizeof (TMP.buf), &my_sp, \ &my_s_err) \ ? 0 \ - : &my_s_ent); \ + : &TMP.ent); \ (ERR) = my_s_err; \ } -#define GET_SERV_BY_PORT(PORT, PROTO, SP, ERR) \ +#define GET_SERV_BY_PORT(PORT, PROTO, SP, ERR, TMP) \ { \ - struct servent my_s_ent, *my_sp; \ + struct servent *my_sp; \ int my_s_err; \ - char my_s_buf[8192]; \ - (SP) = (getservbyport_r((PORT), (PROTO), &my_s_ent, \ - my_s_buf, sizeof (my_s_buf), &my_sp, \ + (SP) = (getservbyport_r((PORT), (PROTO), &TMP.ent, \ + TMP.buf, sizeof (TMP.buf), &my_sp, \ &my_s_err) \ ? 0 \ - : &my_s_ent); \ + : &TMP.ent); \ (ERR) = my_s_err; \ } #else /* returns ptr -- IRIX? */ -#define GET_SERV_BY_NAME(NAME, PROTO, SP, ERR) \ +typedef struct { + struct servent ent; + char buf[8192]; +} GET_SERV_TMP; +#define GET_SERV_BY_NAME(NAME, PROTO, SP, ERR, TMP) \ { \ - struct servent my_s_ent; \ - char my_s_buf[8192]; \ - (SP) = getservbyname_r((NAME), (PROTO), &my_s_ent, \ - my_s_buf, sizeof (my_s_buf)); \ + (SP) = getservbyname_r((NAME), (PROTO), &TMP.ent, \ + TMP.buf, sizeof (TMP.buf)); \ (ERR) = (SP) == NULL; \ } -#define GET_SERV_BY_PORT(PORT, PROTO, SP, ERR) \ +#define GET_SERV_BY_PORT(PORT, PROTO, SP, ERR, TMP) \ { \ - struct servent my_s_ent, *my_sp; \ - char my_s_buf[8192]; \ - my_sp = getservbyport_r((PORT), (PROTO), &my_s_ent, \ - my_s_buf, sizeof (my_s_buf)); \ + struct servent *my_sp; \ + my_sp = getservbyport_r((PORT), (PROTO), &TMP.ent, \ + TMP.buf, sizeof (TMP.buf)); \ (SP) = my_sp; \ (ERR) = my_sp == 0; \ (ERR) = (ERR); /* avoid "unused" warning */ \ @@ -774,8 +785,9 @@ static inline int fai_add_hosts_by_name (const char *name, struct hostent *hp; int i, r; int herr; + GET_HOST_TMP htmp; - GET_HOST_BY_NAME (name, hp, herr); + GET_HOST_BY_NAME (name, hp, herr, htmp); if (hp == 0) return translate_h_errno (herr); for (i = 0; hp->h_addr_list[i]; i++) { @@ -840,6 +852,7 @@ fake_getaddrinfo (const char *name, const char *serv, } else { struct servent *sp; int try_dgram_too = 0, s_err; + GET_SERV_TMP stmp; if (socktype == 0) { try_dgram_too = 1; @@ -847,7 +860,7 @@ fake_getaddrinfo (const char *name, const char *serv, } try_service_lookup: GET_SERV_BY_NAME(serv, socktype == SOCK_STREAM ? "tcp" : "udp", - sp, s_err); + sp, s_err, stmp); if (sp == 0) { if (try_dgram_too) { socktype = SOCK_DGRAM; @@ -952,9 +965,11 @@ fake_getnameinfo (const struct sockaddr *sa, socklen_t len, #endif } else { int herr; + GET_HOST_TMP htmp; + GET_HOST_BY_ADDR((const char *) &sinp->sin_addr, sizeof (struct in_addr), - sa->sa_family, hp, herr); + sa->sa_family, hp, herr, htmp); if (hp == 0) { if (herr == NO_ADDRESS && !(flags & NI_NAMEREQD)) /* ??? */ goto numeric_host; @@ -980,9 +995,11 @@ fake_getnameinfo (const struct sockaddr *sa, socklen_t len, strncpy (service, numbuf, slen); } else { int serr; + GET_SERV_TMP stmp; + GET_SERV_BY_PORT(sinp->sin_port, (flags & NI_DGRAM) ? "udp" : "tcp", - sp, serr); + sp, serr, stmp); if (sp == 0) goto numeric_service; strncpy (service, sp->s_name, slen); @@ -1185,13 +1202,14 @@ getaddrinfo (const char *name, const char *serv, const struct addrinfo *hint, struct hostent *hp; const char *name2 = 0; int i, herr; + GET_HOST_TMP htmp; /* * Current versions of GET_HOST_BY_NAME will fail if the * target hostname has IPv6 addresses only. Make sure it * fails fairly cleanly. */ - GET_HOST_BY_NAME (name, hp, herr); + GET_HOST_BY_NAME (name, hp, herr, htmp); if (hp == 0) { /* * This case probably means it's an IPv6-only name. If diff --git a/src/util/support/plugins.c b/src/util/support/plugins.c index 9d025942ec..bccb522508 100644 --- a/src/util/support/plugins.c +++ b/src/util/support/plugins.c @@ -95,9 +95,14 @@ krb5int_open_plugin (const char *filepath, struct plugin_file_handle **h, struct #if USE_DLOPEN if (!err && (statbuf.st_mode & S_IFMT) == S_IFREG) { void *handle = NULL; +#ifdef RTLD_GROUP +#define PLUGIN_DLOPEN_FLAGS (RTLD_NOW | RTLD_LOCAL | RTLD_GROUP) +#else +#define PLUGIN_DLOPEN_FLAGS (RTLD_NOW | RTLD_LOCAL) +#endif if (!err) { - handle = dlopen(filepath, RTLD_NOW | RTLD_GLOBAL); + handle = dlopen(filepath, PLUGIN_DLOPEN_FLAGS); if (handle == NULL) { const char *e = dlerror(); Tprintf ("dlopen(%s): %s\n", filepath, e); @@ -495,11 +500,11 @@ krb5int_open_plugin_dirs (const char * const *dirnames, } if (dir != NULL) { closedir (dir); } - } #else - /* Until a Windows implementation of this code is implemented */ - err = ENOENT; + /* Until a Windows implementation of this code is implemented */ + err = ENOENT; #endif /* _WIN32 */ + } } if (err == ENOENT) { diff --git a/src/windows/identity/apiversion.txt b/src/windows/identity/apiversion.txt index 008510fba0..72456acd3a 100644 --- a/src/windows/identity/apiversion.txt +++ b/src/windows/identity/apiversion.txt @@ -120,15 +120,41 @@ Date=(TBD) # Flag for error events to signal that the error event has been committed. +khui_action_trigger() +# Function for triggerring an action. +khui_action_set_hwnd() +# internal API. Should not be used by anyone. Basically sets the HWND that should receive event notifications from the UI library. +KEPT_PTR +# error library data type for pointers +_cptr +# type cast macro for pointer types !khc_open_space # name parameter is now a const string !KCDB_ATTRNAME_ISSUE -# Fixed typo \ No newline at end of file +# Fixed typo + +!kherr_val +# is now an inline function instead of a macro + +!kherr_param +# is now a structure instead of an integer type + ++KEPT_NONE +# new constant signifying a NULL parameter + +!_int32, _uint32, _int64, _uint64, _cstr, _tstr, _cptr +# appropriate typecasts added + ++vnull +# macro to insert a NULL parameter + +!_report_cs0, _report_cs1, _report_cs2, _report_cs3 +!_report_sr0, _report_sr1, _report_sr2, _report_sr3 +!_report_mr0, _report_mr1, _report_mr2, _report_mr3 +!_report_ts0, _report_ts1, _report_ts2, _report_ts3 +# modified to use _vnull() instead of 0 for NULL parameters + diff --git a/src/windows/identity/config/Makefile.w2k b/src/windows/identity/config/Makefile.w2k index 81c33546ae..4ea6b8856e 100644 --- a/src/windows/identity/config/Makefile.w2k +++ b/src/windows/identity/config/Makefile.w2k @@ -211,11 +211,20 @@ khcwarn=$(khcwarn) /WX ldebug=$(ldebug) /DEBUG cdebug=$(cdebug) -Os -Zi +# Additionally, suppress conflicting default library directives that we +# might pull in from external libraries. + +!ifndef NODEBUG +lndeflibflag=/NODEFAULTLIB:MSVCRT +!else +lndeflibflag=/NODEFAULTLIB:MSVCRTD +!endif + khcflags=$(cdebug) $(cflags) $(incflags) $(khdefines) $(khcwarn) -khlguiflags=$(ldebug) $(guilflags) -khlconflags=$(ldebug) $(conlflags) -khldllguiflags=$(ldebug) $(dlllflags) -khldllconflags=$(ldebug) $(dlllflags) +khlguiflags=$(ldebug) $(guilflags) $(lndeflibflag) +khlconflags=$(ldebug) $(conlflags) $(lndeflibflag) +khldllguiflags=$(ldebug) $(dlllflags) $(lndeflibflag) +khldllconflags=$(ldebug) $(dlllflags) $(lndeflibflag) !if "$(KH_RUNTIME)" == "STATIC" khcflags=$(khcflags) $(cvarsmt) diff --git a/src/windows/identity/config/Makefile.w32 b/src/windows/identity/config/Makefile.w32 index ed966d7b51..503e44dc1d 100644 --- a/src/windows/identity/config/Makefile.w32 +++ b/src/windows/identity/config/Makefile.w32 @@ -224,11 +224,20 @@ khcwarn=$(khcwarn) /WX ldebug=$(ldebug) /DEBUG cdebug=$(cdebug) -Os -Zi +# Additionally, suppress conflicting default library directives that we +# might pull in from external libraries. + +!ifndef NODEBUG +lndeflibflag=/NODEFAULTLIB:MSVCRT +!else +lndeflibflag=/NODEFAULTLIB:MSVCRTD +!endif + khcflags=$(cdebug) $(cflags) $(incflags) $(khdefines) $(khcwarn) -khlguiflags=$(ldebug) $(guilflags) -khlconflags=$(ldebug) $(conlflags) -khldllguiflags=$(ldebug) $(dlllflags) -khldllconflags=$(ldebug) $(dlllflags) +khlguiflags=$(ldebug) $(guilflags) $(lndeflibflag) +khlconflags=$(ldebug) $(conlflags) $(lndeflibflag) +khldllguiflags=$(ldebug) $(dlllflags) $(lndeflibflag) +khldllconflags=$(ldebug) $(dlllflags) $(lndeflibflag) !if "$(KH_RUNTIME)" == "STATIC" khcflags=$(khcflags) $(cvarsmt) @@ -294,4 +303,28 @@ etag:: .SUFFIXES: .h +# +# Manifest handling +# +# Starting with Visual Studio 8, the C compiler and the linker +# generate manifests so that the applications will link with the +# correct side-by-side DLLs at run-time. These are required for +# correct operation under Windows XP. We also have custom manifests +# which need to be merged with the manifests that VS creates. +# +# The syntax for invoking the _VC_MANIFEST_EMBED_foo macro is: +# $(_VC_MANIFEST_EMBED_???) +# + +!ifndef MT +MT=mt.exe -nologo +!endif + +_VC_MANIFEST_EMBED_EXE= \ +if exist $@.manifest $(MT) -outputresource:$@;1 -manifest $@.manifest + +_VC_MANIFEST_EMBED_DLL=$(_VC_MANIFEST_EMBED_EXE) + +# End of manifest handling + !endif diff --git a/src/windows/identity/include/khmsgtypes.h b/src/windows/identity/include/khmsgtypes.h index b590e056bb..686a9717f6 100644 --- a/src/windows/identity/include/khmsgtypes.h +++ b/src/windows/identity/include/khmsgtypes.h @@ -269,21 +269,38 @@ This message notifies credentials providers that a password change request has been received. + A plug-in handling this message that wishes to participate in the + password change operation is expected to add a + ::khui_new_creds_by_type to the list of participants in the + ::khui_new_creds structure by calling khui_cw_add_type(). + + The password change operation requires user interaction. Any + plug-ins that are participating in the operation need to provide a + user-interface. + Message parameters: - \b vparam : pointer to a ::khui_new_creds structure + + \see khui_cw_add_type(), ::khui_new_creds, ::khui_new_creds_by_type */ #define KMSG_CRED_PASSWORD 16 /*! \brief Initiate the process of obtaining new credentials The UI sends this message to start the process of obtaining new - credentials. See \ref cred_acq for more information about handling this - message. + credentials. See \ref cred_acq for more information about + handling this message. + + A plug-in handling this message that wishes to participate in the + new credentials acquisition operation is expected to add a + ::khui_new_creds_by_type to hte list of participants in the + ::khui_new_creds structure by calling khui_cw_add_type(). Message parameters: - \b vparam : pointer to a ::khui_new_creds structure - \see \ref cred_acq + \see \ref cred_acq, khui_cw_add_type(), ::khui_new_creds, + ::khui_new_creds_by_type */ #define KMSG_CRED_NEW_CREDS 17 @@ -292,8 +309,16 @@ This is a notification sent to individual credentials providers that a specified identity's credentials should be renewed. + A plug-in handling this message that wishes to participate in the + renew credentials operation is expected to add a + ::khui_new_creds_by_type to the list of participants in the + ::khui_new_creds structure by calling khui_cw_add_type(). + Message parameters: - \b vparam : Pointer to a khui_new_creds object + + \see khui_cw_add_type(), ::khui_new_creds, + ::khui_new_creds_by_type */ #define KMSG_CRED_RENEW_CREDS 18 @@ -493,7 +518,6 @@ dialog completion. Currently, the dialog messages are: - - ::KMSG_CRED_INITIAL_CREDS - ::KMSG_CRED_NEW_CREDS - ::KMSG_CRED_RENEW_CREDS - ::KMSG_CRED_DIALOG_SETUP diff --git a/src/windows/identity/kconfig/api.c b/src/windows/identity/kconfig/api.c index 83aa0657cd..ef182fe32c 100644 --- a/src/windows/identity/kconfig/api.c +++ b/src/windows/identity/kconfig/api.c @@ -677,6 +677,7 @@ khcint_open_space(kconf_conf_space * parent, HKEY pkey = NULL; HKEY ckey = NULL; wchar_t buf[KCONF_MAXCCH_NAME]; + size_t cb_regpath = 0; if(!parent) p = conf_root; @@ -686,10 +687,7 @@ khcint_open_space(kconf_conf_space * parent, if(n_sname >= KCONF_MAXCCH_NAME || n_sname <= 0) return KHM_ERROR_INVALID_PARAM; - /* SAFE: buf: buffer size == KCONF_MAXCCH_NAME * wchar_t > - n_sname * wchar_t */ - wcsncpy(buf, sname, n_sname); - buf[n_sname] = L'\0'; + StringCchCopyN(buf, ARRAYLENGTH(buf), sname, n_sname); /* see if there is already a config space by this name. if so, return it. Note that if the configuration space is specified @@ -760,19 +758,18 @@ khcint_open_space(kconf_conf_space * parent, /*SAFE: p->regpath: is valid since it was set using this same function. */ /*SAFE: buf: see above */ - c->regpath = PMALLOC((wcslen(p->regpath) + wcslen(buf) + 2) * sizeof(wchar_t)); + cb_regpath = (wcslen(p->regpath) + wcslen(buf) + 2) * sizeof(wchar_t); + c->regpath = PMALLOC(cb_regpath); assert(c->regpath != NULL); -#pragma warning( push ) -#pragma warning( disable: 4995 ) /*SAFE: c->regpath: allocated above to be big enough */ /*SAFE: p->regpath: see above */ - wcscpy(c->regpath, p->regpath); - wcscat(c->regpath, L"\\"); + StringCbCopy(c->regpath, cb_regpath, p->regpath); + StringCbCat(c->regpath, cb_regpath, L"\\"); + /*SAFE: buf: see above */ - wcscat(c->regpath, buf); -#pragma warning( pop ) + StringCbCat(c->regpath, cb_regpath, buf); khcint_space_hold(c); diff --git a/src/windows/identity/kcreddb/credential.c b/src/windows/identity/kcreddb/credential.c index 6886cc5b6c..98854dab46 100644 --- a/src/windows/identity/kcreddb/credential.c +++ b/src/windows/identity/kcreddb/credential.c @@ -943,12 +943,18 @@ kcdb_creds_is_equal(khm_handle vcred1, kcdb_cred_lock_read(); if(!kcdb_cred_is_active_cred(vcred1) || - !kcdb_cred_is_active_cred(vcred2)) + !kcdb_cred_is_active_cred(vcred2)) { + + code = FALSE; goto _exit; + } + if(vcred1 == vcred2) { + code = TRUE; goto _exit; + } cred1 = vcred1; diff --git a/src/windows/identity/kcreddb/credtype.c b/src/windows/identity/kcreddb/credtype.c index e57b22b530..89e0175f00 100644 --- a/src/windows/identity/kcreddb/credtype.c +++ b/src/windows/identity/kcreddb/credtype.c @@ -281,11 +281,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credtype_describe( *cbbuf = s; rv = KHM_ERROR_TOO_LONG; } else { -#pragma warning(push) -#pragma warning(disable:4995) - wcscpy(buf, str); /* str is one of the string fields in t->ct which has - been validated when the type was registered. */ -#pragma warning(pop) + StringCbCopy(buf, *cbbuf, str); *cbbuf = s; } } else { @@ -321,10 +317,7 @@ KHMEXP khm_int32 KHMAPI kcdb_credtype_get_name( *cbbuf = s; rv = KHM_ERROR_TOO_LONG; } else { -#pragma warning(push) -#pragma warning(disable: 4995) - wcscpy(buf, t->ct.name); /* t->ct.name was validated when the type was registered */ -#pragma warning(pop) + StringCbCopy(buf, *cbbuf, t->ct.name); *cbbuf = s; } } else { diff --git a/src/windows/identity/kcreddb/type.c b/src/windows/identity/kcreddb/type.c index baf5f9730d..c1215f5834 100644 --- a/src/windows/identity/kcreddb/type.c +++ b/src/windows/identity/kcreddb/type.c @@ -391,9 +391,11 @@ FtIntervalToString(LPFILETIME data, wchar_t * buffer, khm_size * cb_buf) t = ibuf + wcslen(ibuf); if(h == 1) { - LoadString(hinst_kcreddb, IDS_IVL_1H, t, ARRAYLENGTH(ibuf) - wcslen(ibuf)); + LoadString(hinst_kcreddb, IDS_IVL_1H, t, + (int) (ARRAYLENGTH(ibuf) - wcslen(ibuf))); } else { - LoadString(hinst_kcreddb, IDS_IVL_H, fbuf, ARRAYLENGTH(fbuf)); + LoadString(hinst_kcreddb, IDS_IVL_H, fbuf, + (int) ARRAYLENGTH(fbuf)); StringCbPrintf(t, sizeof(ibuf) - wcslen(ibuf)*sizeof(wchar_t), fbuf, h); } } @@ -415,9 +417,11 @@ FtIntervalToString(LPFILETIME data, wchar_t * buffer, khm_size * cb_buf) t = ibuf + wcslen(ibuf); if(m == 1) { - LoadString(hinst_kcreddb, IDS_IVL_1M, t, ARRAYLENGTH(ibuf) - wcslen(ibuf)); + LoadString(hinst_kcreddb, IDS_IVL_1M, t, + (int) (ARRAYLENGTH(ibuf) - wcslen(ibuf))); } else { - LoadString(hinst_kcreddb, IDS_IVL_M, fbuf, ARRAYLENGTH(fbuf)); + LoadString(hinst_kcreddb, IDS_IVL_M, fbuf, + (int) ARRAYLENGTH(fbuf)); StringCbPrintf(t, sizeof(ibuf) - wcslen(ibuf)*sizeof(wchar_t), fbuf, m); } } @@ -434,9 +438,11 @@ FtIntervalToString(LPFILETIME data, wchar_t * buffer, khm_size * cb_buf) t = ibuf + wcslen(ibuf); if(s == 1) { - LoadString(hinst_kcreddb, IDS_IVL_1S, t, ARRAYLENGTH(ibuf) - wcslen(ibuf)); + LoadString(hinst_kcreddb, IDS_IVL_1S, t, + (int) (ARRAYLENGTH(ibuf) - wcslen(ibuf))); } else { - LoadString(hinst_kcreddb, IDS_IVL_S, fbuf, ARRAYLENGTH(fbuf)); + LoadString(hinst_kcreddb, IDS_IVL_S, fbuf, + (int) ARRAYLENGTH(fbuf)); StringCbPrintf(t, sizeof(ibuf) - wcslen(ibuf)*sizeof(wchar_t), fbuf, s); } } diff --git a/src/windows/identity/nidmgrdll/Makefile b/src/windows/identity/nidmgrdll/Makefile index d3f50021c6..701a79d7de 100644 --- a/src/windows/identity/nidmgrdll/Makefile +++ b/src/windows/identity/nidmgrdll/Makefile @@ -113,8 +113,10 @@ SCLIB= $(DLLFILE): $(OBJFILES) $(RESFILES) $(DLLGUILINK) $(LIBFILES) $(SDKLIBFILES) $(SCLIB) + $(_VC_MANIFEST_EMBED_DLL) all: mkdirs $(DLLFILE) clean:: $(RM) $(DLLFILE) + $(RM) $(DLLFILE).manifest diff --git a/src/windows/identity/plugins/common/krb5common.c b/src/windows/identity/plugins/common/krb5common.c index de1cea4abf..5ba59df4e7 100644 --- a/src/windows/identity/plugins/common/krb5common.c +++ b/src/windows/identity/plugins/common/krb5common.c @@ -31,6 +31,7 @@ #ifdef DEBUG #include #endif +#include /**************************************/ /* khm_krb5_error(): */ diff --git a/src/windows/identity/plugins/common/krb5common.h b/src/windows/identity/plugins/common/krb5common.h index bd6337192a..df3db93ae1 100644 --- a/src/windows/identity/plugins/common/krb5common.h +++ b/src/windows/identity/plugins/common/krb5common.h @@ -33,9 +33,13 @@ #ifndef NO_KRB5 int khm_krb5_error(krb5_error_code rc, LPCSTR FailedFunctionName, - int FreeContextFlag, krb5_context *ctx, - krb5_ccache *cache); + int FreeContextFlag, krb5_context *ctx, + krb5_ccache *cache); +int +khm_krb5_get_error_string(krb5_error_code rc, + wchar_t * buffer, + khm_size cb_buffer); int khm_krb5_initialize(khm_handle ident, krb5_context *, krb5_ccache *); diff --git a/src/windows/identity/plugins/krb4/Makefile b/src/windows/identity/plugins/krb4/Makefile index b1ad963f08..c5226aaaa0 100644 --- a/src/windows/identity/plugins/krb4/Makefile +++ b/src/windows/identity/plugins/krb4/Makefile @@ -70,6 +70,7 @@ $(OBJ)\krb4config.c: krbconfig.csv $(CONFDIR)\csvschema.cfg $(DLLFILE): $(OBJFILES) $(VERRESFILE) $(MSGRESFILE) $(DLLGUILINK) $(LIBFILES) $(SDKLIBFILES) $(SCLIB) + $(_VC_MANIFEST_EMBED_DLL) all: mkdirs $(MSGRESFILE) $(DLLFILE) lang diff --git a/src/windows/identity/plugins/krb4/errorfuncs.c b/src/windows/identity/plugins/krb4/errorfuncs.c index 5adc66b914..f1aa63d88b 100644 --- a/src/windows/identity/plugins/krb4/errorfuncs.c +++ b/src/windows/identity/plugins/krb4/errorfuncs.c @@ -27,6 +27,8 @@ #include #include +#include + extern void (__cdecl *pinitialize_krb_error_func)(); extern void (__cdecl *pinitialize_kadm_error_table)(); @@ -89,8 +91,7 @@ LPSTR err_describe(LPSTR buf, size_t len, long code) case kadm_err_base: break; default: - strncpy(buf, com_err_msg, len); - buf[len-1] = '\0'; + StringCbCopyA(buf, len, com_err_msg); return buf; } @@ -194,8 +195,7 @@ LPSTR err_describe(LPSTR buf, size_t len, long code) break; } if(com_err_msg != buf) { - strncpy(buf, com_err_msg, len); - buf[len-1] = '\0'; + StringCbCopyA(buf, len, com_err_msg); } cp = buf + strlen(buf); *cp++ = '\n'; diff --git a/src/windows/identity/plugins/krb4/krb4funcs.c b/src/windows/identity/plugins/krb4/krb4funcs.c index 8928f71fde..18c05981fc 100644 --- a/src/windows/identity/plugins/krb4/krb4funcs.c +++ b/src/windows/identity/plugins/krb4/krb4funcs.c @@ -243,10 +243,10 @@ khm_krb5_get_profile_file(LPSTR confname, UINT szConfname) { GetWindowsDirectoryA(confname,szConfname); confname[szConfname-1] = '\0'; - strncat(confname, "\\",sizeof(confname)-strlen(confname)); - confname[szConfname-1] = '\0'; - strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname)); - confname[szConfname-1] = '\0'; + + StringCchCatA(confname, szConfname, "\\"); + StringCchCatA(confname, szConfname, KRB5_FILE); + return FALSE; } @@ -254,7 +254,7 @@ khm_krb5_get_profile_file(LPSTR confname, UINT szConfname) if (configFile) { - strncpy(confname, *configFile, szConfname); + StringCchCopyA(confname, szConfname, *configFile); pkrb5_free_config_files(configFile); } @@ -262,10 +262,9 @@ khm_krb5_get_profile_file(LPSTR confname, UINT szConfname) { GetWindowsDirectoryA(confname,szConfname); confname[szConfname-1] = '\0'; - strncat(confname, "\\",sizeof(confname)-strlen(confname)); - confname[szConfname-1] = '\0'; - strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname)); - confname[szConfname-1] = '\0'; + + StringCchCatA(confname, szConfname, "\\"); + StringCchCatA(confname, szConfname, KRB5_FILE); } return FALSE; @@ -274,51 +273,41 @@ khm_krb5_get_profile_file(LPSTR confname, UINT szConfname) BOOL khm_get_krb4_con_file(LPSTR confname, UINT szConfname) { - if (hKrb5 && !hKrb4) - { // hold krb.con where krb5.ini is located - CHAR krbConFile[MAX_PATH]=""; - LPSTR pFind; + if (hKrb5 && !hKrb4) { + // hold krb.con where krb5.ini is located + CHAR krbConFile[MAX_PATH]=""; + LPSTR pFind; - //strcpy(krbConFile, CLeashApp::m_krbv5_profile->first_file->filename); - if (khm_krb5_get_profile_file(krbConFile, sizeof(krbConFile))) - { - GetWindowsDirectoryA(krbConFile,sizeof(krbConFile)); - krbConFile[MAX_PATH-1] = '\0'; - strncat(krbConFile, "\\",sizeof(krbConFile)-strlen(krbConFile)); - krbConFile[MAX_PATH-1] = '\0'; - strncat(krbConFile, KRB5_FILE,sizeof(krbConFile)-strlen(krbConFile)); - krbConFile[MAX_PATH-1] = '\0'; - } + if (khm_krb5_get_profile_file(krbConFile, sizeof(krbConFile))) { + GetWindowsDirectoryA(krbConFile,sizeof(krbConFile)); + krbConFile[MAX_PATH-1] = '\0'; - pFind = strrchr(krbConFile, '\\'); - if (pFind) - { - *pFind = 0; - strncat(krbConFile, "\\",sizeof(krbConFile)-strlen(krbConFile)); - krbConFile[MAX_PATH-1] = '\0'; - strncat(krbConFile, KRB_FILE,sizeof(krbConFile)-strlen(krbConFile)); - krbConFile[MAX_PATH-1] = '\0'; - } - else - krbConFile[0] = 0; - - strncpy(confname, krbConFile, szConfname); + StringCbCatA(krbConFile, sizeof(krbConFile), "\\"); + } + + pFind = strrchr(krbConFile, '\\'); + + if (pFind) { + *pFind = '\0'; + + StringCbCatA(krbConFile, sizeof(krbConFile), "\\"); + StringCbCatA(krbConFile, sizeof(krbConFile), KRB_FILE); + } else { + krbConFile[0] = '\0'; + } + + StringCchCopyA(confname, szConfname, krbConFile); + } else if (hKrb4) { + unsigned int size = szConfname; + memset(confname, '\0', szConfname); + if (!pkrb_get_krbconf2(confname, &size)) { + GetWindowsDirectoryA(confname,szConfname); confname[szConfname-1] = '\0'; - } - else if (hKrb4) - { - unsigned int size = szConfname; - memset(confname, '\0', szConfname); - if (!pkrb_get_krbconf2(confname, &size)) - { // Error has happened - GetWindowsDirectoryA(confname,szConfname); - confname[szConfname-1] = '\0'; - strncat(confname, "\\",szConfname-strlen(confname)); - confname[szConfname-1] = '\0'; - strncat(confname,KRB_FILE,szConfname-strlen(confname)); - confname[szConfname-1] = '\0'; - } - } + StringCchCatA(confname, szConfname, "\\"); + StringCchCatA(confname, szConfname, KRB_FILE); + } + } + return FALSE; } @@ -433,7 +422,12 @@ wchar_t * khm_krb5_get_realm_list(void) wchar_t * d; if (!khm_get_krb4_con_file(krb_conf,sizeof(krb_conf)) && - (file = fopen(krb_conf, "rt"))) +#if _MSC_VER >= 1400 + !fopen_s(&file, krb_conf, "rt") +#else + (file = fopen(krb_conf, "rt")) +#endif + ) { char lineBuf[256]; @@ -519,25 +513,32 @@ make_postfix(const char * base, const char * postfix, char ** rcopy) { - int base_size; - int ret_size; + size_t base_size; + size_t ret_size; char * copy = 0; char * ret = 0; + size_t t; + + if (FAILED(StringCbLengthA(base, STRSAFE_MAX_CCH * sizeof(char), &t))) + goto cleanup; + + base_size = t + 1; + + if (FAILED(StringCbLengthA(postfix, STRSAFE_MAX_CCH * sizeof(char), &t))) + goto cleanup; + + ret_size = base_size + t + 1; - base_size = (int) strlen(base) + 1; - ret_size = base_size + (int) strlen(postfix) + 1; copy = malloc(base_size); ret = malloc(ret_size); if (!copy || !ret) goto cleanup; - strncpy(copy, base, base_size); - copy[base_size - 1] = 0; - - strncpy(ret, base, base_size); - strncpy(ret + (base_size - 1), postfix, ret_size - (base_size - 1)); - ret[ret_size - 1] = 0; + StringCbCopyNA(copy, base_size, base, base_size); + StringCbCopyNA(ret, ret_size, base, base_size); + StringCbCopyNA(ret + (base_size - 1), ret_size - (base_size - 1), + postfix, ret_size - (base_size - 1)); cleanup: if (!copy || !ret) { diff --git a/src/windows/identity/plugins/krb4/krb4newcreds.c b/src/windows/identity/plugins/krb4/krb4newcreds.c index b3dd7cea76..407c30fedf 100644 --- a/src/windows/identity/plugins/krb4/krb4newcreds.c +++ b/src/windows/identity/plugins/krb4/krb4newcreds.c @@ -115,10 +115,15 @@ void k4_update_data(k4_dlg_data * d) { khm_boolean k4_should_identity_get_k4(khm_handle ident) { khm_int32 idflags = 0; + khm_int32 t = TRUE; khm_handle csp_ident = NULL; khm_handle csp_k4 = NULL; khm_boolean get_k4 = TRUE; + if (KHM_SUCCEEDED(khc_read_int32(csp_params, L"Krb4NewCreds", &t)) && + !t) + return FALSE; + if (KHM_FAILED(kcdb_identity_get_flags(ident, &idflags))) return FALSE; @@ -325,8 +330,7 @@ void k4_handle_wmnc_notify(k4_dlg_data * d, l = (khui_htwnd_link *) lParam; - wcsncpy(wid, l->id, l->id_len); - wid[l->id_len] = 0; + StringCchCopyN(wid, ARRAYLENGTH(wid), l->id, l->id_len); wids = wcschr(wid, L':'); if (!wids) diff --git a/src/windows/identity/plugins/krb5/Makefile b/src/windows/identity/plugins/krb5/Makefile index 67475ee010..cfee907b2a 100644 --- a/src/windows/identity/plugins/krb5/Makefile +++ b/src/windows/identity/plugins/krb5/Makefile @@ -74,6 +74,7 @@ $(OBJ)\krb5config.c: krbconfig.csv $(CONFDIR)\csvschema.cfg $(DLLFILE): $(OBJFILES) $(VERRESFILE) $(DLLGUILINK) $(MSGRESFILE) $(LIBFILES) $(SDKLIBFILES) $(SCLIB) + $(_VC_MANIFEST_EMBED_DLL) $(MSGRESFILE): $(OBJ)\krb5_msgs.rc diff --git a/src/windows/identity/plugins/krb5/datarep.c b/src/windows/identity/plugins/krb5/datarep.c index 97d629eb4c..92eabf4daa 100644 --- a/src/windows/identity/plugins/krb5/datarep.c +++ b/src/windows/identity/plugins/krb5/datarep.c @@ -274,6 +274,36 @@ krb5flags_toString(const void *d, } } +khm_int32 KHMAPI +kvno_toString(const void * data, khm_size cbdata, + wchar_t *destbuf, khm_size *pcbdestbuf, + khm_int32 flags) +{ + int resid = 0; + int kvno; + wchar_t buf[256]; + size_t cblength; + + if (cbdata != sizeof(khm_int32)) + return KHM_ERROR_INVALID_PARAM; + + kvno = *((khm_int32 *) data); + + StringCbPrintf(buf, sizeof(buf), L"#%d", kvno); + + StringCbLength(buf, ARRAYLENGTH(buf), &cblength); + cblength += sizeof(wchar_t); + + if (!destbuf || *pcbdestbuf < cblength) { + *pcbdestbuf = cblength; + return KHM_ERROR_TOO_LONG; + } else { + StringCbCopy(destbuf, *pcbdestbuf, buf); + *pcbdestbuf = cblength; + return KHM_ERROR_SUCCESS; + } +} + khm_int32 serialize_krb5_addresses(krb5_address ** a, void * buf, size_t * pcbbuf) { diff --git a/src/windows/identity/plugins/krb5/datarep.h b/src/windows/identity/plugins/krb5/datarep.h index eeb6970dad..90f1923fa0 100644 --- a/src/windows/identity/plugins/krb5/datarep.h +++ b/src/windows/identity/plugins/krb5/datarep.h @@ -59,6 +59,11 @@ khm_int32 KHMAPI krb5flags_toString(const void *, khm_size, wchar_t *, khm_size *, khm_int32); +khm_int32 KHMAPI +kvno_toString(const void * data, khm_size cbdata, + wchar_t *destbuf, khm_size *pcbdestbuf, + khm_int32 flags); + khm_int32 KHMAPI renew_for_cb(khm_handle cred, khm_int32 id, void * buffer, khm_size * pcbsize); diff --git a/src/windows/identity/plugins/krb5/krb5configcc.c b/src/windows/identity/plugins/krb5/krb5configcc.c index 66e7a08d00..425d13430f 100644 --- a/src/windows/identity/plugins/krb5/krb5configcc.c +++ b/src/windows/identity/plugins/krb5/krb5configcc.c @@ -29,16 +29,16 @@ #define _WIN32_WINNT 0x501 #endif +#define STRSAFE_NO_DEPRECATE + #include #include #include #include #include - -#pragma warning(push) -#pragma warning(disable: 4995) #include -#pragma warning(pop) + +#include typedef struct tag_k5_file_cc { wchar_t path[MAX_PATH]; @@ -97,7 +97,7 @@ void k5_add_file_cc(k5_ccc_data * d, wchar_t * path) { /* see if it's there first */ for (i=0; i < d->n_file_ccs; i++) { - if(!wcsicmp(d->file_ccs[i].path, path)) + if(!_wcsicmp(d->file_ccs[i].path, path)) return; } @@ -232,7 +232,7 @@ BOOL k5_ccc_get_mod(k5_ccc_dlg_data * d) { for (i=0; i < d->work.n_file_ccs; i++) { for (j=0; j < d->save.n_file_ccs; j++) { - if (!wcsicmp(d->work.file_ccs[i].path, + if (!_wcsicmp(d->work.file_ccs[i].path, d->save.file_ccs[j].path)) break; } @@ -372,7 +372,7 @@ k5_ccconfig_dlgproc(HWND hwnd, return TRUE; /* nothing to add */ for (i=0; i < d->work.n_file_ccs; i++) { - if (!wcsicmp(path, d->work.file_ccs[i].path)) { + if (!_wcsicmp(path, d->work.file_ccs[i].path)) { /* allow the user to correct case, as appropriate */ StringCbCopy(d->work.file_ccs[i].path, @@ -522,7 +522,7 @@ k5_ccconfig_dlgproc(HWND hwnd, LVNI_SELECTED)) != -1) { ListView_GetItemText(lv, lv_idx, 0, buf, ARRAYLENGTH(buf)); for (i=0; i < d->work.n_file_ccs; i++) { - if (!wcsicmp(buf, d->work.file_ccs[i].path)) { + if (!_wcsicmp(buf, d->work.file_ccs[i].path)) { k5_del_file_cc(&d->work, i); break; } diff --git a/src/windows/identity/plugins/krb5/krb5configdlg.c b/src/windows/identity/plugins/krb5/krb5configdlg.c index ad64d48833..65f010840e 100644 --- a/src/windows/identity/plugins/krb5/krb5configdlg.c +++ b/src/windows/identity/plugins/krb5/krb5configdlg.c @@ -24,17 +24,16 @@ /* $Id$ */ +#define STRSAFE_NO_DEPRECATE + #include #include #include #include #include - -#pragma warning(push) -#pragma warning(disable: 4995) #include -#pragma warning(pop) +#include typedef struct tag_k5_realm_kdc { wchar_t name[K5_MAXCCH_HOST]; @@ -134,12 +133,12 @@ k5_parse_boolean(const char *s) const char *const *p; for(p=conf_yes; *p; p++) { - if (!stricmp(*p,s)) + if (!_stricmp(*p,s)) return 1; } for(p=conf_no; *p; p++) { - if (!stricmp(*p,s)) + if (!_stricmp(*p,s)) return 0; } @@ -409,7 +408,7 @@ k5_read_config_data(k5_config_data * d) { sizeof(kdc_name), values[i]); for (j=0; j < d->realms[s].n_kdcs; j++) - if (!wcsicmp(kdc_name, d->realms[s].kdcs[j].name)) + if (!_wcsicmp(kdc_name, d->realms[s].kdcs[j].name)) break; if (j < d->realms[s].n_kdcs) { @@ -436,7 +435,7 @@ k5_read_config_data(k5_config_data * d) { AnsiStrToUnicode(kdc_name, sizeof(kdc_name), values[i]); for (j=0; j < d->realms[s].n_kdcs; j++) - if (!wcsicmp(kdc_name, d->realms[s].kdcs[j].name)) + if (!_wcsicmp(kdc_name, d->realms[s].kdcs[j].name)) break; if (j < d->realms[s].n_kdcs) { @@ -478,7 +477,7 @@ k5_read_config_data(k5_config_data * d) { AnsiStrToUnicode(wdr_to, sizeof(wdr_to), dr_to); for (j=0; j < d->n_realms; j++) { - if (!wcsicmp(wdr_to, d->realms[j].realm)) + if (!_wcsicmp(wdr_to, d->realms[j].realm)) break; } @@ -588,7 +587,7 @@ k5_write_config_data(k5_config_data * d) { UnicodeStrToAnsi(astr, sizeof(astr), d->config_file); - if (stricmp(config_file, astr)) { + if (_stricmp(config_file, astr)) { assert(FALSE); } @@ -1965,7 +1964,7 @@ k5_realms_dlgproc(HWND hwnd, (d->realms[i].flags & K5_RDFLAG_DELETED)) continue; - if (!wcsicmp(d->realms[i].realm, pdisp->item.pszText)) + if (!_wcsicmp(d->realms[i].realm, pdisp->item.pszText)) break; } @@ -2084,7 +2083,7 @@ k5_realms_dlgproc(HWND hwnd, (d->realms[r].kdcs[k].flags & K5_RKFLAG_DELETED)) continue; - if (!wcsicmp(d->realms[r].kdcs[k].name, + if (!_wcsicmp(d->realms[r].kdcs[k].name, pdisp->item.pszText)) break; } @@ -2283,8 +2282,8 @@ k5_realms_dlgproc(HWND hwnd, (d->realms[r].domain_maps[m].flags & K5_DMFLAG_DELETED)) continue; - if (!wcsicmp(d->realms[r].domain_maps[m].name, - pdisp->item.pszText)) + if (!_wcsicmp(d->realms[r].domain_maps[m].name, + pdisp->item.pszText)) break; } diff --git a/src/windows/identity/plugins/krb5/krb5configid.c b/src/windows/identity/plugins/krb5/krb5configid.c index ccc38941a6..ebec91e997 100644 --- a/src/windows/identity/plugins/krb5/krb5configid.c +++ b/src/windows/identity/plugins/krb5/krb5configid.c @@ -24,16 +24,16 @@ /* $Id$ */ +#define STRSAFE_NO_DEPRECATE + #include #include #include #include #include - -#pragma warning(push) -#pragma warning(disable: 4995) #include -#pragma warning(pop) + +#include typedef struct tag_k5_id_dlg_data { khui_config_init_data cfg; @@ -164,7 +164,7 @@ k5_id_is_mod(HWND hw, k5_id_dlg_data * d) { SendDlgItemMessage(hw, IDC_CFG_PUBLICIP, IPM_GETADDRESS, 0, (LPARAM) &dwaddress); - if (wcsicmp(ccache, d->ccache) || + if (_wcsicmp(ccache, d->ccache) || d->tc_renew.current != d->renew_life || @@ -259,7 +259,7 @@ k5_id_write_params(HWND hw, k5_id_dlg_data * d) { GetDlgItemText(hw, IDC_CFG_CCACHE, ccache, ARRAYLENGTH(ccache)); if (SUCCEEDED(StringCbLength(ccache, sizeof(ccache), &cb)) && - wcsicmp(ccache, d->ccache)) { + _wcsicmp(ccache, d->ccache)) { khc_write_string(csp_ident, L"DefaultCCName", ccache); StringCbCopy(d->ccache, sizeof(d->ccache), ccache); } else { diff --git a/src/windows/identity/plugins/krb5/krb5configids.c b/src/windows/identity/plugins/krb5/krb5configids.c index 4eebb9c629..579b9f712d 100644 --- a/src/windows/identity/plugins/krb5/krb5configids.c +++ b/src/windows/identity/plugins/krb5/krb5configids.c @@ -24,6 +24,8 @@ /* $Id$ */ +#define STRSAFE_NO_DEPRECATE + #include #include #include diff --git a/src/windows/identity/plugins/krb5/krb5funcs.c b/src/windows/identity/plugins/krb5/krb5funcs.c index dab522c5dc..1f7b2bdad1 100644 --- a/src/windows/identity/plugins/krb5/krb5funcs.c +++ b/src/windows/identity/plugins/krb5/krb5funcs.c @@ -434,12 +434,15 @@ static long get_tickets_from_cache(krb5_context ctx, if ( !pkrb5_decode_ticket(&KRBv5Credentials.ticket, &tkt)) { ti = tkt->enc_part.enctype; kcdb_cred_set_attr(cred, attr_id_tkt_enctype, &ti, sizeof(ti)); + ti = tkt->enc_part.kvno; + kcdb_cred_set_attr(cred, attr_id_kvno, &ti, sizeof(ti)); pkrb5_free_ticket(ctx, tkt); tkt = NULL; } ti = KRBv5Credentials.keyblock.enctype; kcdb_cred_set_attr(cred, attr_id_key_enctype, &ti, sizeof(ti)); + kcdb_cred_set_attr(cred, KCDB_ATTR_LOCATION, wcc_name, KCDB_CBSIZE_AUTO); @@ -1734,10 +1737,10 @@ khm_krb5_get_profile_file(LPSTR confname, UINT szConfname) { GetWindowsDirectoryA(confname,szConfname); confname[szConfname-1] = '\0'; - strncat(confname, "\\",sizeof(confname)-strlen(confname)); - confname[szConfname-1] = '\0'; - strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname)); - confname[szConfname-1] = '\0'; + + StringCchCatA(confname, szConfname, "\\"); + StringCchCatA(confname, szConfname, KRB5_FILE); + return FALSE; } @@ -1745,7 +1748,7 @@ khm_krb5_get_profile_file(LPSTR confname, UINT szConfname) if (configFile) { - strncpy(confname, *configFile, szConfname); + StringCchCopyA(confname, szConfname, *configFile); pkrb5_free_config_files(configFile); } @@ -1753,10 +1756,8 @@ khm_krb5_get_profile_file(LPSTR confname, UINT szConfname) { GetWindowsDirectoryA(confname,szConfname); confname[szConfname-1] = '\0'; - strncat(confname, "\\",sizeof(confname)-strlen(confname)); - confname[szConfname-1] = '\0'; - strncat(confname, KRB5_FILE,sizeof(confname)-strlen(confname)); - confname[szConfname-1] = '\0'; + StringCchCatA(confname, szConfname, "\\"); + StringCchCatA(confname, szConfname, KRB5_FILE); } return FALSE; @@ -1773,25 +1774,19 @@ khm_get_krb4_con_file(LPSTR confname, UINT szConfname) if (khm_krb5_get_profile_file(krbConFile, sizeof(krbConFile))) { GetWindowsDirectoryA(krbConFile,sizeof(krbConFile)); krbConFile[MAX_PATH-1] = '\0'; - strncat(krbConFile, "\\",sizeof(krbConFile)-strlen(krbConFile)); - krbConFile[MAX_PATH-1] = '\0'; - strncat(krbConFile, KRB5_FILE,sizeof(krbConFile)-strlen(krbConFile)); - krbConFile[MAX_PATH-1] = '\0'; + StringCchCatA(confname, szConfname, "\\"); } pFind = strrchr(krbConFile, '\\'); if (pFind) { - *pFind = 0; - strncat(krbConFile, "\\",sizeof(krbConFile)-strlen(krbConFile)); - krbConFile[MAX_PATH-1] = '\0'; - strncat(krbConFile, KRB_FILE,sizeof(krbConFile)-strlen(krbConFile)); - krbConFile[MAX_PATH-1] = '\0'; + *pFind = '\0'; + StringCchCatA(krbConFile, ARRAYLENGTH(krbConFile), "\\"); + StringCchCatA(krbConFile, ARRAYLENGTH(krbConFile), KRB_FILE); } else - krbConFile[0] = 0; - - strncpy(confname, krbConFile, szConfname); - confname[szConfname-1] = '\0'; + krbConFile[0] = '\0'; + + StringCchCopyA(confname, szConfname, krbConFile); } else if (hKrb4) { unsigned int size = szConfname; @@ -1800,10 +1795,8 @@ khm_get_krb4_con_file(LPSTR confname, UINT szConfname) { // Error has happened GetWindowsDirectoryA(confname,szConfname); confname[szConfname-1] = '\0'; - strncat(confname, "\\",szConfname-strlen(confname)); - confname[szConfname-1] = '\0'; - strncat(confname,KRB_FILE,szConfname-strlen(confname)); - confname[szConfname-1] = '\0'; + StringCchCatA(confname, szConfname, "\\"); + StringCchCatA(confname, szConfname, KRB_FILE); } } return FALSE; @@ -1922,7 +1915,12 @@ khm_krb5_get_realm_list(void) wchar_t * d; if (!khm_get_krb4_con_file(krb_conf,sizeof(krb_conf)) && - (file = fopen(krb_conf, "rt"))) +#if _MSC_VER >= 1400 + !fopen_s(&file, krb_conf, "rt") +#else + (file = fopen(krb_conf, "rt")) +#endif + ) { char lineBuf[256]; @@ -2151,7 +2149,8 @@ khm_int32 KHMAPI khm_krb5_creds_is_equal(khm_handle vcred1, khm_handle vcred2, void * dummy) { if (kcdb_creds_comp_attr(vcred1, vcred2, KCDB_ATTR_LOCATION) || kcdb_creds_comp_attr(vcred1, vcred2, attr_id_key_enctype) || - kcdb_creds_comp_attr(vcred1, vcred2, attr_id_tkt_enctype)) + kcdb_creds_comp_attr(vcred1, vcred2, attr_id_tkt_enctype) || + kcdb_creds_comp_attr(vcred1, vcred2, attr_id_kvno)) return 1; else return 0; diff --git a/src/windows/identity/plugins/krb5/krb5identpro.c b/src/windows/identity/plugins/krb5/krb5identpro.c index f52e3441dd..b263e6bf30 100644 --- a/src/windows/identity/plugins/krb5/krb5identpro.c +++ b/src/windows/identity/plugins/krb5/krb5identpro.c @@ -212,7 +212,7 @@ update_crossfeed(khui_new_creds * nc, (WPARAM) idx, (LPARAM) srealm); - if (!wcsicmp(srealm, un_realm) && wcscmp(srealm, un_realm)) { + if (!_wcsicmp(srealm, un_realm) && wcscmp(srealm, un_realm)) { /* differ only by case */ StringCchCopy(un_realm, ARRAYLENGTH(un) - (un_realm - un), @@ -260,7 +260,7 @@ update_crossfeed(khui_new_creds * nc, (WPARAM) idx, (LPARAM) srealm); - if (!wcsicmp(srealm, realm) && wcscmp(srealm, realm)) { + if (!_wcsicmp(srealm, realm) && wcscmp(srealm, realm)) { StringCbCopy(realm, sizeof(realm), srealm); SetWindowText(d->hw_realm, srealm); @@ -1145,7 +1145,7 @@ k5_ident_update(khm_int32 msg_type, khm_krb5_canon_cc_name(w_ccname, sizeof(w_ccname)); khm_krb5_canon_cc_name(wid_ccname, sizeof(wid_ccname)); - if (!wcsicmp(w_ccname, wid_ccname)) + if (!_wcsicmp(w_ccname, wid_ccname)) kcdb_identity_set_default_int(ident); _iu_cleanup: @@ -1499,7 +1499,7 @@ DWORD WINAPI k5_ccname_monitor_thread(LPVOID lpParameter) { new_ccname[0] = L'\0'; } - if (wcsicmp(new_ccname, reg_ccname)) { + if (_wcsicmp(new_ccname, reg_ccname)) { k5_refresh_default_identity(ctx); StringCbCopy(reg_ccname, sizeof(reg_ccname), new_ccname); } diff --git a/src/windows/identity/plugins/krb5/krb5main.c b/src/windows/identity/plugins/krb5/krb5main.c index ee85355a0b..97ef85ee95 100644 --- a/src/windows/identity/plugins/krb5/krb5main.c +++ b/src/windows/identity/plugins/krb5/krb5main.c @@ -36,23 +36,27 @@ khm_int32 type_id_enctype = -1; khm_int32 type_id_addr_list = -1; khm_int32 type_id_krb5_flags = -1; khm_int32 type_id_krb5_princ = -1; +khm_int32 type_id_kvno = -1; BOOL type_regd_enctype = FALSE; BOOL type_regd_addr_list = FALSE; BOOL type_regd_krb5_flags = FALSE; BOOL type_regd_krb5_princ = FALSE; +BOOL type_regd_kvno = FALSE; khm_int32 attr_id_key_enctype = -1; khm_int32 attr_id_tkt_enctype = -1; khm_int32 attr_id_addr_list = -1; khm_int32 attr_id_krb5_flags = -1; khm_int32 attr_id_krb5_ccname = -1; +khm_int32 attr_id_kvno = -1; BOOL attr_regd_key_enctype = FALSE; BOOL attr_regd_tkt_enctype = FALSE; BOOL attr_regd_addr_list = FALSE; BOOL attr_regd_krb5_flags = FALSE; BOOL attr_regd_krb5_ccname = FALSE; +BOOL attr_regd_kvno = FALSE; khm_handle csp_plugins = NULL; khm_handle csp_krbcred = NULL; @@ -196,6 +200,31 @@ KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module) { type_regd_krb5_flags = TRUE; } + if (KHM_FAILED(kcdb_type_get_id(TYPENAME_KVNO, &type_id_kvno))) { + kcdb_type type; + kcdb_type *t32; + + kcdb_type_get_info(KCDB_TYPE_INT32, &t32); + + type.id = KCDB_TYPE_INVALID; + type.name = TYPENAME_KVNO; + type.flags = KCDB_TYPE_FLAG_CB_FIXED; + type.cb_max = t32->cb_max; + type.cb_min = t32->cb_min; + type.isValid = t32->isValid; + type.comp = t32->comp; + type.dup = t32->dup; + type.toString = kvno_toString; + + rv = kcdb_type_register(&type, &type_id_kvno); + kcdb_type_release_info(t32); + + if (KHM_FAILED(rv)) + goto _exit; + + type_regd_kvno = TRUE; + } + /* Register common attributes */ if(KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_KEY_ENCTYPE, &attr_id_key_enctype))) { kcdb_attrib attrib; @@ -328,6 +357,32 @@ KHMEXP khm_int32 KHMAPI init_module(kmm_module h_module) { attr_regd_krb5_ccname = TRUE; } + if (KHM_FAILED(kcdb_attrib_get_id(ATTRNAME_KVNO, &attr_id_kvno))) { + kcdb_attrib attrib; + wchar_t sbuf[KCDB_MAXCCH_SHORT_DESC]; + wchar_t lbuf[KCDB_MAXCCH_LONG_DESC]; + /* although we are loading a long description, it still fits + in the short description buffer */ + + ZeroMemory(&attrib, sizeof(attrib)); + + attrib.name = ATTRNAME_KVNO; + attrib.id = KCDB_ATTR_INVALID; + attrib.type = type_id_kvno; + attrib.flags = KCDB_ATTR_FLAG_TRANSIENT; + LoadString(hResModule, IDS_KVNO_SHORT_DESC, sbuf, ARRAYLENGTH(sbuf)); + LoadString(hResModule, IDS_KVNO_LONG_DESC, lbuf, ARRAYLENGTH(lbuf)); + attrib.short_desc = sbuf; + attrib.long_desc = lbuf; + + rv = kcdb_attrib_register(&attrib, &attr_id_kvno); + + if (KHM_FAILED(rv)) + goto _exit; + + attr_regd_kvno = TRUE; + } + rv = kmm_get_plugins_config(0, &csp_plugins); if(KHM_FAILED(rv)) goto _exit; @@ -359,6 +414,8 @@ KHMEXP khm_int32 KHMAPI exit_module(kmm_module h_module) { kcdb_attrib_unregister(attr_id_krb5_flags); if(attr_regd_krb5_ccname) kcdb_attrib_unregister(attr_id_krb5_ccname); + if(attr_regd_kvno) + kcdb_attrib_unregister(attr_id_kvno); if(type_regd_enctype) kcdb_type_unregister(type_id_enctype); @@ -366,6 +423,8 @@ KHMEXP khm_int32 KHMAPI exit_module(kmm_module h_module) { kcdb_type_unregister(type_id_addr_list); if(type_regd_krb5_flags) kcdb_type_unregister(type_id_krb5_flags); + if(type_regd_kvno) + kcdb_type_unregister(type_id_kvno); if(csp_params) { khc_close_space(csp_params); diff --git a/src/windows/identity/plugins/krb5/krbcred.h b/src/windows/identity/plugins/krb5/krbcred.h index 3e64b00772..4b9373d081 100644 --- a/src/windows/identity/plugins/krb5/krbcred.h +++ b/src/windows/identity/plugins/krb5/krbcred.h @@ -62,12 +62,14 @@ typedef enum tag_k5_lsa_import { #define TYPENAME_ADDR_LIST L"AddrList" #define TYPENAME_KRB5_FLAGS L"Krb5Flags" #define TYPENAME_KRB5_PRINC L"Krb5Principal" +#define TYPENAME_KVNO L"Kvno" #define ATTRNAME_KEY_ENCTYPE L"KeyEncType" #define ATTRNAME_TKT_ENCTYPE L"TktEncType" #define ATTRNAME_ADDR_LIST L"AddrList" #define ATTRNAME_KRB5_FLAGS L"Krb5Flags" #define ATTRNAME_KRB5_CCNAME L"Krb5CCName" +#define ATTRNAME_KVNO L"Kvno" void init_krb(); void exit_krb(); @@ -84,6 +86,7 @@ extern khm_int32 type_id_enctype; extern khm_int32 type_id_addr_list; extern khm_int32 type_id_krb5_flags; extern khm_int32 type_id_krb5_princ; +extern khm_int32 type_id_kvno; extern BOOL type_regd_krb5_princ; @@ -92,6 +95,7 @@ extern khm_int32 attr_id_tkt_enctype; extern khm_int32 attr_id_addr_list; extern khm_int32 attr_id_krb5_flags; extern khm_int32 attr_id_krb5_ccname; +extern khm_int32 attr_id_kvno; extern khm_ui_4 k5_commctl_version; diff --git a/src/windows/identity/plugins/krb5/lang/en_us/langres.rc b/src/windows/identity/plugins/krb5/lang/en_us/langres.rc index c54bdb4b1a..49673c3781 100644 --- a/src/windows/identity/plugins/krb5/lang/en_us/langres.rc +++ b/src/windows/identity/plugins/krb5/lang/en_us/langres.rc @@ -521,6 +521,8 @@ BEGIN IDS_CFG_RE_MMK "Toggle &master KDC" IDS_CFG_RE_MND "&Add new domain mapping" IDS_CFG_RE_MDD "&Remove domain mapping" + IDS_KVNO_LONG_DESC "Key version number" + IDS_KVNO_SHORT_DESC "Kvno" END #endif // English (U.S.) resources diff --git a/src/windows/identity/plugins/krb5/langres.h b/src/windows/identity/plugins/krb5/langres.h index edda7dd02d..da8a62ffda 100644 --- a/src/windows/identity/plugins/krb5/langres.h +++ b/src/windows/identity/plugins/krb5/langres.h @@ -132,6 +132,8 @@ #define IDS_CFG_RE_MMK 214 #define IDS_CFG_RE_MND 215 #define IDS_CFG_RE_MDD 216 +#define IDS_KVNO_SHORT_DESC 217 +#define IDS_KVNO_LONG_DESC 218 #define IDC_NCK5_RENEWABLE 1002 #define IDC_NCK5_FORWARDABLE 1004 #define IDC_NCK5_REALM 1005 @@ -204,7 +206,7 @@ // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 118 +#define _APS_NEXT_RESOURCE_VALUE 219 #define _APS_NEXT_COMMAND_VALUE 40002 #define _APS_NEXT_CONTROL_VALUE 1079 #define _APS_NEXT_SYMED_VALUE 101 diff --git a/src/windows/identity/ui/Makefile b/src/windows/identity/ui/Makefile index e09d9f8c7c..35c19bdba1 100644 --- a/src/windows/identity/ui/Makefile +++ b/src/windows/identity/ui/Makefile @@ -27,7 +27,7 @@ MODULE=ui EXEFILE=$(BINDIR)\netidmgr.exe -MANIFESTFILE=$(BINDIR)\netidmgr.exe.manifest +MANIFESTFILE=$(BINDIR)\netidmgr.exe.static.manifest OBJFILES= \ $(OBJ)\main.obj \ @@ -88,7 +88,6 @@ $(MANIFESTFILE): netidmgr.manifest.$(CPU).$(KH_CLVER).debug !endif $(CP) $** $@ - !if ("$(CPU)" == "IA64" ) || ("$(CPU)" == "AMD64" ) || ("$(CPU)" == "ALPHA64" ) SCLIB=bufferoverflowu.lib !else @@ -97,6 +96,6 @@ SCLIB= $(EXEFILE): $(OBJFILES) $(RESFILES) $(LIBFILES) $(EXEGUILINK) $(SDKLIBFILES) $(SCLIB) + $(_VC_MANIFEST_EMBED_EXE) $(MANIFESTFILE) -all: mkdirs $(EXEFILE) $(MANIFESTFILE) - +all: mkdirs $(MANIFESTFILE) $(EXEFILE) diff --git a/src/windows/identity/ui/credwnd.c b/src/windows/identity/ui/credwnd.c index b68a3f953f..31df6bdf70 100644 --- a/src/windows/identity/ui/credwnd.c +++ b/src/windows/identity/ui/credwnd.c @@ -4113,7 +4113,7 @@ cw_wm_command(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) /* a hyperlink was activated */ khui_htwnd_link * l; l = (khui_htwnd_link *) lParam; - wcsncpy(wid, l->id, l->id_len); + StringCchCopyN(wid, ARRAYLENGTH(wid), l->id, l->id_len); wid[l->id_len] = 0; if(!wcscmp(wid, L"NewCreds")) { diff --git a/src/windows/identity/ui/debugfuncs.c b/src/windows/identity/ui/debugfuncs.c index b18ef42bb7..7df6e9d651 100644 --- a/src/windows/identity/ui/debugfuncs.c +++ b/src/windows/identity/ui/debugfuncs.c @@ -202,8 +202,12 @@ void khm_start_file_log(void) { khm_get_file_log_path(sizeof(temppath), temppath); + logfile = NULL; +#if _MSC_VER >= 1400 + _wfopen_s(&logfile, temppath, L"w"); +#else logfile = _wfopen(temppath, L"w"); - +#endif kherr_add_ctx_handler(debug_event_handler, KHERR_CTX_BEGIN | KHERR_CTX_END | diff --git a/src/windows/identity/ui/htwnd.c b/src/windows/identity/ui/htwnd.c index a9472585b4..9507fbdd0c 100644 --- a/src/windows/identity/ui/htwnd.c +++ b/src/windows/identity/ui/htwnd.c @@ -121,6 +121,8 @@ typedef struct khui_htwnd_data_t { wchar_t * text; int scroll_left; int scroll_top; + int ext_width; + int ext_height; COLORREF bk_color; HCURSOR hc_hand; int l_pixel_y; @@ -630,6 +632,8 @@ static LRESULT htw_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) int align; int y; wchar_t * par_start; + int ext_width = 0; + int ext_height = 0; d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); @@ -645,8 +649,11 @@ static LRESULT htw_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) GetClientRect(hwnd, &r); +#ifdef DRAW_HTWND_CLIENT_EDGE + /* for the moment, we are skipping on the client edge. */ if(d->flags & KHUI_HTWND_CLIENTEDGE) DrawEdge(hdc, &r, EDGE_SUNKEN, BF_ADJUST | BF_RECT | BF_FLAT); +#endif hbk = CreateSolidBrush(RGB(255,255,255)); FillRect(hdc, &r, hbk); @@ -728,8 +735,6 @@ static LRESULT htw_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) p = par_start; format_unwind(&s_stack, s_start); /* unwind format stack */ - //MoveToEx(hdc, x, y + l_height, NULL); - p_width = 0; while(*p) { @@ -766,13 +771,14 @@ static LRESULT htw_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) SetTextColor(hdc, format_color(&s_stack)); GetTextExtentPoint32(hdc, p, (int)(c - p), &s); - rd.left = x + p_width; - rd.top = y; - rd.right = x + p_width + s.cx; - rd.bottom = y + l_height; + rd.left = x + p_width - d->scroll_left; + rd.top = y - d->scroll_top; + rd.right = x + p_width + s.cx - d->scroll_left; + rd.bottom = y + l_height - d->scroll_top; if(IntersectRect(&rt, &rd, &r)) { - DrawText(hdc, p, (int)(c - p), &rt, DT_BOTTOM | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX); + DrawText(hdc, p, (int)(c - p), &rd, + DT_BOTTOM | DT_LEFT | DT_SINGLELINE | DT_NOPREFIX); } p_width += s.cx; @@ -782,12 +788,86 @@ static LRESULT htw_paint(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } } + if (p_width > ext_width) + ext_width = p_width; + y += l_height; par_start = p; } + if (y > ext_height) + ext_height = y; + EndPaint(hwnd, &ps); + if (d->ext_width < ext_width) { + SCROLLINFO si; + LONG l; + + /* the extents need to be adjusted. But first check if we + have exactly the right scroll bars we need. */ + if ((ext_width > (r.right - r.left) && + !(d->flags & KHUI_HTWND_HSCROLL)) || + (ext_height > (r.bottom - r.top) && + !(d->flags & KHUI_HTWND_VSCROLL)) || + + (ext_width <= (r.right - r.left) && + (d->flags & KHUI_HTWND_HSCROLL)) || + (ext_height <= (r.bottom - r.top) && + (d->flags & KHUI_HTWND_VSCROLL))) { + + /* need to add scroll bars */ + if (ext_width > (r.right - r.left)) + d->flags |= KHUI_HTWND_HSCROLL; + else + d->flags &= ~KHUI_HTWND_HSCROLL; + + if (ext_height > (r.bottom - r.top)) + d->flags |= KHUI_HTWND_VSCROLL; + else + d->flags &= ~KHUI_HTWND_VSCROLL; + + l = GetWindowLongPtr(hwnd, GWL_STYLE); + l &= ~(WS_HSCROLL | WS_VSCROLL); + + l |= ((d->flags & KHUI_HTWND_HSCROLL) ? WS_HSCROLL : 0) | + ((d->flags & KHUI_HTWND_VSCROLL) ? WS_VSCROLL : 0); + + SetWindowLongPtr(hwnd, GWL_STYLE, l); + + InvalidateRect(hwnd, NULL, FALSE); + /* since the client area changed, we do another redraw + before updating the scroll bar positions. */ + } else { + d->ext_width = ext_width; + d->ext_height = ext_height; + + if (d->flags & KHUI_HTWND_HSCROLL) { + ZeroMemory(&si, sizeof(si)); + si.cbSize = sizeof(si); + si.fMask = SIF_ALL | SIF_DISABLENOSCROLL; + si.nMin = 0; + si.nMax = ext_width; + si.nPage = r.right - r.left; + si.nPos = d->scroll_left; + + SetScrollInfo(hwnd, SB_HORZ, &si, TRUE); + } + + if (d->flags & KHUI_HTWND_VSCROLL) { + ZeroMemory(&si, sizeof(si)); + si.cbSize = sizeof(si); + si.fMask = SIF_ALL | SIF_DISABLENOSCROLL; + si.nMin = 0; + si.nMax = ext_height; + si.nPage = r.bottom - r.top; + si.nPos = d->scroll_top; + + SetScrollInfo(hwnd, SB_VERT, &si, TRUE); + } + } + } + return 0; } @@ -798,231 +878,328 @@ LRESULT CALLBACK khui_htwnd_proc(HWND hwnd, ) { switch(uMsg) { - case WM_CREATE: - { - CREATESTRUCT * cs; - khui_htwnd_data * d; - size_t cbsize; + case WM_CREATE: + { + CREATESTRUCT * cs; + khui_htwnd_data * d; + size_t cbsize; - cs = (CREATESTRUCT *) lParam; + cs = (CREATESTRUCT *) lParam; - d = PMALLOC(sizeof(*d)); - ZeroMemory(d, sizeof(*d)); + d = PMALLOC(sizeof(*d)); + ZeroMemory(d, sizeof(*d)); - if(cs->dwExStyle & WS_EX_TRANSPARENT) { - d->flags |= KHUI_HTWND_TRANSPARENT; - } - if(cs->dwExStyle & WS_EX_CLIENTEDGE) { - d->flags |= KHUI_HTWND_CLIENTEDGE; - } - d->id = (int)(INT_PTR) cs->hMenu; + if(cs->dwExStyle & WS_EX_TRANSPARENT) { + d->flags |= KHUI_HTWND_TRANSPARENT; + } + if(cs->dwExStyle & WS_EX_CLIENTEDGE) { + d->flags |= KHUI_HTWND_CLIENTEDGE; + } + if(cs->style & WS_HSCROLL) { + d->flags |= KHUI_HTWND_HSCROLL; + } + if(cs->style & WS_VSCROLL) { + d->flags |= KHUI_HTWND_VSCROLL; + } + d->id = (int)(INT_PTR) cs->hMenu; - d->active_link = -1; - d->bk_color = RGB(255,255,255); - d->hc_hand = LoadCursor(NULL, IDC_HAND); + d->active_link = -1; + d->bk_color = RGB(255,255,255); + d->hc_hand = LoadCursor(NULL, IDC_HAND); - if(SUCCEEDED(StringCbLength(cs->lpszName, KHUI_HTWND_MAXCB_TEXT, &cbsize))) { - cbsize += sizeof(wchar_t); - d->text = PMALLOC(cbsize); - StringCbCopy(d->text, cbsize, cs->lpszName); - } + if(SUCCEEDED(StringCbLength(cs->lpszName, KHUI_HTWND_MAXCB_TEXT, &cbsize))) { + cbsize += sizeof(wchar_t); + d->text = PMALLOC(cbsize); + StringCbCopy(d->text, cbsize, cs->lpszName); + } + + /* this is just a flag to the WM_PAINT handler that the + extents haven't been set yet. */ + d->ext_width = -1; #pragma warning(push) #pragma warning(disable: 4244) - SetWindowLongPtr(hwnd, 0, (LONG_PTR) d); + SetWindowLongPtr(hwnd, 0, (LONG_PTR) d); #pragma warning(pop) - return 0; + return 0; + } + break; + + case WM_SETTEXT: + { + wchar_t * newtext; + size_t cbsize; + khui_htwnd_data * d; + BOOL rv; + + d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); + newtext = (wchar_t *) lParam; + + if(d->text) { + PFREE(d->text); + d->text = NULL; } - break; - case WM_SETTEXT: - { - wchar_t * newtext; - size_t cbsize; - khui_htwnd_data * d; - BOOL rv; + if(SUCCEEDED(StringCbLength(newtext, KHUI_HTWND_MAXCB_TEXT, &cbsize))) { + cbsize += sizeof(wchar_t); + d->text = PMALLOC(cbsize); + StringCbCopy(d->text, cbsize, newtext); + rv = TRUE; + } else + rv = FALSE; + + clear_styles(d); + + d->ext_width = -1; + d->scroll_left = 0; + d->scroll_top = 0; - d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); - newtext = (wchar_t *) lParam; + InvalidateRect(hwnd, NULL, TRUE); - if(d->text) { - PFREE(d->text); - d->text = NULL; + return rv; + } + break; + + case WM_DESTROY: + { + khui_htwnd_data * d; + int i; + + d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); + if(d->text) + PFREE(d->text); + d->text = 0; + + if(d->links) { + for(i=0;imax_links;i++) { + if(d->links[i]) + PFREE(d->links[i]); } + PFREE(d->links); + } - if(SUCCEEDED(StringCbLength(newtext, KHUI_HTWND_MAXCB_TEXT, &cbsize))) { - cbsize += sizeof(wchar_t); - d->text = PMALLOC(cbsize); - StringCbCopy(d->text, cbsize, newtext); - rv = TRUE; - } else - rv = FALSE; + clear_styles(d); - clear_styles(d); + PFREE(d); + } + break; - InvalidateRect(hwnd, NULL, TRUE); + case WM_ERASEBKGND: + { + khui_htwnd_data * d; + d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); - return rv; - } - break; + if(d->flags & KHUI_HTWND_TRANSPARENT) + return TRUE; - case WM_DESTROY: - { - khui_htwnd_data * d; - int i; - - d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); - if(d->text) - PFREE(d->text); - d->text = 0; - - if(d->links) { - for(i=0;imax_links;i++) { - if(d->links[i]) - PFREE(d->links[i]); - } - PFREE(d->links); - } + return FALSE; + } + + case WM_PAINT: + htw_paint(hwnd, uMsg, wParam, lParam); + break; + + case WM_SETCURSOR: + { + khui_htwnd_data * d; - clear_styles(d); + if(hwnd != (HWND)wParam) + break; + + d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); - PFREE(d); + if(d->active_link >= 0) { + SetCursor(d->hc_hand); + return TRUE; } - break; + } + break; - case WM_ERASEBKGND: - { - khui_htwnd_data * d; - d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); + case WM_SETFOCUS: + { + khui_htwnd_data * d; - if(d->flags & KHUI_HTWND_TRANSPARENT) - return TRUE; + d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); - return FALSE; - } + d->flags |= KHUI_HTWND_FOCUS; - case WM_PAINT: - htw_paint(hwnd, uMsg, wParam, lParam); - break; + InvalidateRect(hwnd, NULL, TRUE); + } + break; - case WM_SETCURSOR: - { - khui_htwnd_data * d; + case WM_KILLFOCUS: + { + khui_htwnd_data * d; - if(hwnd != (HWND)wParam) - break; + d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); - d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); + d->flags &= ~KHUI_HTWND_FOCUS; - if(d->active_link >= 0) { - SetCursor(d->hc_hand); - return TRUE; - } - } - break; + InvalidateRect(hwnd, NULL, TRUE); + } + break; + + case WM_LBUTTONDOWN: + { + khui_htwnd_data * d; - case WM_SETFOCUS: - { - khui_htwnd_data * d; + d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); - d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); + d->md_link = d->active_link; - d->flags |= KHUI_HTWND_FOCUS; + SetCapture(hwnd); + } + break; + + case WM_LBUTTONUP: + { + khui_htwnd_data * d; - InvalidateRect(hwnd, NULL, TRUE); + d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); + + if(d->md_link == d->active_link && d->md_link >= 0) { + /* clicked */ + SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(d->id, BN_CLICKED), (LPARAM) d->links[d->md_link]); } - break; - case WM_KILLFOCUS: - { - khui_htwnd_data * d; + ReleaseCapture(); + } + break; - d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); + case WM_HSCROLL: + { + khui_htwnd_data * d; + int old_pos; + int new_pos; + int ext; + SCROLLINFO si; + RECT r; + + d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); + + old_pos = new_pos = d->scroll_left; + ext = d->ext_width; + + switch(HIWORD(wParam)) { + case SB_THUMBTRACK: + case SB_THUMBPOSITION: + ZeroMemory(&si, sizeof(si)); + si.cbSize = sizeof(si); + si.fMask = SIF_TRACKPOS; + GetScrollInfo(hwnd, SB_HORZ, &si); + new_pos = si.nTrackPos; + break; - d->flags &= ~KHUI_HTWND_FOCUS; + case SB_LINELEFT: + new_pos -= ext / 12; /* arbitrary unit */ + break; - InvalidateRect(hwnd, NULL, TRUE); + case SB_LINERIGHT: + new_pos += ext / 12; /* arbitrary unit */ + break; + + case SB_PAGELEFT: + GetClientRect(hwnd, &r); + new_pos -= r.right - r.left; + break; + + case SB_PAGERIGHT: + GetClientRect(hwnd, &r); + new_pos += r.right - r.left; + break; } - break; - case WM_LBUTTONDOWN: - { - khui_htwnd_data * d; + if (new_pos == old_pos) + break; - d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); + GetClientRect(hwnd, &r); - d->md_link = d->active_link; +#if 0 + if (new_pos > ext - (r.right - r.left)) + new_pos = ext - (r.right - r.left); +#endif + if (new_pos > ext) + new_pos = ext; - SetCapture(hwnd); - } - break; + if (new_pos < 0) + new_pos = 0; - case WM_LBUTTONUP: - { - khui_htwnd_data * d; + if (new_pos == old_pos) + break; - d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); + ZeroMemory(&si, sizeof(si)); + si.cbSize = sizeof(si); + si.fMask = SIF_POS; + si.nPos = new_pos; + SetScrollInfo(hwnd, SB_HORZ, &si, TRUE); + /* note that Windows sometimes adjusts the position after + setting it with SetScrollInfo. We have to look it up + again to see what value it ended up at. */ + GetScrollInfo(hwnd, SB_HORZ, &si); + new_pos = si.nPos; + + if (new_pos == old_pos) + break; - if(d->md_link == d->active_link && d->md_link >= 0) { - /* clicked */ - SendMessage(GetParent(hwnd), WM_COMMAND, MAKEWPARAM(d->id, BN_CLICKED), (LPARAM) d->links[d->md_link]); - } + d->scroll_left = new_pos; - ReleaseCapture(); - } - break; + ScrollWindow(hwnd, old_pos - new_pos, 0, NULL, NULL); - case WM_MOUSEMOVE: - { - khui_htwnd_data * d; - int i; - POINT p; - int nl; + return 0; + } + break; - p.x = GET_X_LPARAM(lParam); - p.y = GET_Y_LPARAM(lParam); - d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); + case WM_MOUSEMOVE: + { + khui_htwnd_data * d; + int i; + POINT p; + int nl; + + d = (khui_htwnd_data *)(LONG_PTR) GetWindowLongPtr(hwnd, 0); + p.x = GET_X_LPARAM(lParam) + d->scroll_left; + p.y = GET_Y_LPARAM(lParam) + d->scroll_top; - for(i=0; in_links; i++) { - if(d->links && d->links[i] && PtInRect(&(d->links[i]->r), p)) - break; - } + for(i=0; in_links; i++) { + if(d->links && d->links[i] && PtInRect(&(d->links[i]->r), p)) + break; + } - if(i == d->n_links) - nl = -1; - else - nl = i; + if(i == d->n_links) + nl = -1; + else + nl = i; - if(d->active_link != nl) { - if(d->active_link >= 0) { - if(d->flags & KHUI_HTWND_TRANSPARENT) + if(d->active_link != nl) { + if(d->active_link >= 0) { + if(d->flags & KHUI_HTWND_TRANSPARENT) { HWND parent = GetParent(hwnd); if(parent) { InvalidateRect(parent, NULL, TRUE); } } - /* although we are invalidating the rect before setting active_link, - WM_PAINT will not be issued until wndproc returns */ - InvalidateRect(hwnd, &(d->links[d->active_link]->r), TRUE); - } - d->active_link = nl; - if(d->active_link >= 0) { - /* although we are invalidating the rect before setting active_link, - WM_PAINT will not be issued until wndproc returns */ - if(d->flags & KHUI_HTWND_TRANSPARENT) + /* although we are invalidating the rect before setting active_link, + WM_PAINT will not be issued until wndproc returns */ + InvalidateRect(hwnd, &(d->links[d->active_link]->r), TRUE); + } + d->active_link = nl; + if(d->active_link >= 0) { + /* although we are invalidating the rect before setting active_link, + WM_PAINT will not be issued until wndproc returns */ + if(d->flags & KHUI_HTWND_TRANSPARENT) { HWND parent = GetParent(hwnd); if(parent) { InvalidateRect(parent, NULL, TRUE); } } - InvalidateRect(hwnd, &(d->links[d->active_link]->r), TRUE); - } + InvalidateRect(hwnd, &(d->links[d->active_link]->r), TRUE); } } - break; + } + break; } return DefWindowProc(hwnd, uMsg,wParam,lParam); diff --git a/src/windows/identity/ui/htwnd.h b/src/windows/identity/ui/htwnd.h index e83dbb6844..2ca8c261b8 100644 --- a/src/windows/identity/ui/htwnd.h +++ b/src/windows/identity/ui/htwnd.h @@ -40,6 +40,8 @@ We currently support the following tags: #define KHUI_HTWND_TRANSPARENT 1 #define KHUI_HTWND_CLIENTEDGE 2 +#define KHUI_HTWND_HSCROLL 4 +#define KHUI_HTWND_VSCROLL 8 #define KHUI_HTWND_FOCUS 2048 #define KHUI_HTWND_CLASS L"KhmHtWnd" diff --git a/src/windows/identity/ui/newcredwnd.c b/src/windows/identity/ui/newcredwnd.c index 56c79294bc..e263f7c87e 100644 --- a/src/windows/identity/ui/newcredwnd.c +++ b/src/windows/identity/ui/newcredwnd.c @@ -967,7 +967,8 @@ nc_handle_wm_command(HWND hwnd, l->param_len < ARRAYLENGTH(sparam) && l->param_len > 0) { - wcsncpy(sparam, l->param, l->param_len); + StringCchCopyN(sparam, ARRAYLENGTH(sparam), + l->param, l->param_len); sparam[l->param_len] = L'\0'; } else { @@ -1006,7 +1007,7 @@ nc_handle_wm_command(HWND hwnd, } /* if it was for us, then we need to process the message */ - if(!wcsicmp(sid, CTLINKID_SWITCH_PANEL)) { + if(!_wcsicmp(sid, CTLINKID_SWITCH_PANEL)) { khm_int32 credtype; khui_new_creds_by_type * t; @@ -1021,10 +1022,10 @@ nc_handle_wm_command(HWND hwnd, WMNC_DIALOG_SWITCH_PANEL), 0); } - } else if (!wcsicmp(sid, L"NotDef")) { + } else if (!_wcsicmp(sid, L"NotDef")) { d->nc->set_default = FALSE; nc_update_credtext(d); - } else if (!wcsicmp(sid, L"MakeDef")) { + } else if (!_wcsicmp(sid, L"MakeDef")) { d->nc->set_default = TRUE; nc_update_credtext(d); } diff --git a/src/windows/identity/uilib/action.c b/src/windows/identity/uilib/action.c index 29699476b3..f96ec5deec 100644 --- a/src/windows/identity/uilib/action.c +++ b/src/windows/identity/uilib/action.c @@ -29,6 +29,8 @@ #include #include +#include + khui_action_ref khui_main_menu[] = { MENU_SUBMENU(KHUI_MENU_FILE), MENU_SUBMENU(KHUI_MENU_CRED), diff --git a/src/windows/identity/uilib/alert.c b/src/windows/identity/uilib/alert.c index 3d06a07e22..96436543a7 100644 --- a/src/windows/identity/uilib/alert.c +++ b/src/windows/identity/uilib/alert.c @@ -28,6 +28,8 @@ #include #include +#include + /*********************************************************************** Alerter ***********************************************************************/ diff --git a/src/windows/identity/uilib/configui.c b/src/windows/identity/uilib/configui.c index 9aa88cd287..79e570820a 100644 --- a/src/windows/identity/uilib/configui.c +++ b/src/windows/identity/uilib/configui.c @@ -30,6 +30,8 @@ #include #include +#include + khm_int32 cfgui_node_serial; LONG init_once = 0; CRITICAL_SECTION cs_cfgui; diff --git a/src/windows/identity/uilib/creddlg.c b/src/windows/identity/uilib/creddlg.c index 154ed18eb4..458218d90b 100644 --- a/src/windows/identity/uilib/creddlg.c +++ b/src/windows/identity/uilib/creddlg.c @@ -28,6 +28,8 @@ #include #include +#include + #define CW_ALLOC_INCR 8 static void cw_free_prompts(khui_new_creds * c); diff --git a/src/windows/identity/uilib/khnewcred.h b/src/windows/identity/uilib/khnewcred.h index 45df19779f..e561eb1083 100644 --- a/src/windows/identity/uilib/khnewcred.h +++ b/src/windows/identity/uilib/khnewcred.h @@ -415,24 +415,50 @@ typedef struct tag_khui_new_creds { #define KHUI_MAXCB_PNAME (KHUI_MAXCCH_PNAME * sizeof(wchar_t)) /*! \brief A descriptor of a panel in the new credentials acquisition tab + + When processing certain credentials messages such as + ::KMSG_CRED_PASSWORD, ::KMSG_CRED_NEW_CREDS, + ::KMSG_CRED_RENEW_CREDS, a pointer to a ::khui_new_creds structure + will be passed in to the message handler. If the handler of the + message needs to add one or more credentials types as participants + of the operation, the handler will need to call khui_cw_add_type() + and specify a ::khui_new_creds_by_type structure. + + Note that the memory address passed in to the call to + khui_cw_add_type() will not be copied. Therefore, the block of + memory should remain as-is for the lifetime of the + ::khui_new_creds structure or until it is removed with a call to + khui_cw_del_type(). + + Some of the credentials messages that require specifying a + ::khui_new_creds_by_type structure require providing a + user-interface. In these cases, the fields marked for providing a + UI may be required to hold valid values. If the message does not + require providing a UI, these fields will be ignored. */ typedef struct tag_khui_new_creds_by_type { khui_new_creds * nc; /*!< Internal use. Do not set */ khm_int32 flags; /*!< Internal use. Do not set */ khm_int32 type; /*!< The identifier of the credentials - type */ + type. This is a credentials type + identifier allocated with a call to + kcdb_credtype_register(). */ khm_int32 type_deps[KHUI_MAX_TYPE_DEPS]; /*!< credentials types that this credential type depends on. Each element defines a credentials type identifier that this type depends - on for this operation. */ + on for this operation. The number + of valid values in this array + should be specified in the \a + n_type_deps field. */ khm_size n_type_deps; /*!< Number of dependencies listed above. Should be between 0 and - ::KHUI_MAX_TYPE_DEPS */ + ::KHUI_MAX_TYPE_DEPS. Specify 0 if + there are no dependencies. */ khm_size ordinal; /*!< The requested ordinal. The UI would attempt to place this panel at @@ -446,29 +472,49 @@ typedef struct tag_khui_new_creds_by_type { wchar_t *name; /*!< Name of the panel (localized, optional). If NULL, the localized name of the credentials type is - used. */ + used. Only used if providing a + user-interface. */ - HICON icon; /*!< Icon for the panel (optional) */ + HICON icon; /*!< Icon for the panel (optional). + Only used if providing a + user-interface. */ wchar_t *tooltip; /*!< Tooltip for the panel (localized, optional). If NULL, no tooltip will - be assigned for the panel */ + be assigned for the panel. Only + used if providing a + user-interface. */ HMODULE h_module; /*!< Handle to the module containing - the dialog resource */ - - LPWSTR dlg_template; /*!< The dialog resource */ - DLGPROC dlg_proc; /*!< The dialog procedure */ + the dialog resource. Only used if + providing a user-interface. */ + + LPWSTR dlg_template; /*!< The dialog resource. Only used + if providing a user-interface. */ + DLGPROC dlg_proc; /*!< The dialog procedure. Only used + if providing a user-interface. */ + + HWND hwnd_panel; /*!< The dialog window. Once the + dialog panel is created, a handle to + the panel will be assigned here. + Note that the handle is assigned + after a successful call to + CreateDialogParam and hence would + not be available when handling the + WM_INITDIALOG message from the + dialog procedure. Only used of + providing a user-interface. */ - HWND hwnd_panel; /*!< The dialog window */ HWND hwnd_tc; /*!< Internal use. Do not set */ wchar_t *credtext; /*!< A brief description of the current state of this cred - type. (localized, optional) */ + type. (localized, optional). Only + used if providing a + user-interface. */ LPARAM aux; /*!< auxilliary field. For use by the - credential provider */ + plug-in. */ } khui_new_creds_by_type; /*!\name Flags for khui_new_creds_by_type @@ -652,6 +698,22 @@ khui_cw_unlock_nc(khui_new_creds * c); See the description of ::khui_new_cred_panel for information on how to populate it to describe a credentials type panel. + Note that the structure pointed to by \a t is added by reference. + The memory pointed to by \a t is not copied. Hence, the block of + memory and any other blocks pointed to by the + ::khui_new_creds_by_type structure located there should remain + intact for the lifetime of the ::khui_new_creds structure pointed + to by \a c or until the credentials type panel is removed from the + ::khui_new_creds structure with a call to khui_cw_del_type(). + + Generally, a plug-in that calls this function should allocate a + block of memory to contain the ::khui_new_creds_by_type structure, + fill it in and then pass in the address in a call to + khui_cw_add_type() while handling a ::KMSG_CRED_PASSWORD, + ::KMSG_CRED_NEW_CREDS or ::KMSG_CRED_RENEW_CREDS message. Then + the plug-in should remove the reference with a call to + khui_cw_del_type() while processing ::KMSG_CRED_END. + \see khui_cw_del_type() \see \ref cred_acq_panel_spec \see ::khui_new_cred_panel diff --git a/src/windows/identity/util/perfstat.c b/src/windows/identity/util/perfstat.c index 6cf8ae44a0..c9996b31cd 100644 --- a/src/windows/identity/util/perfstat.c +++ b/src/windows/identity/util/perfstat.c @@ -247,9 +247,14 @@ perf_dump(char * file) { perf_once(); EnterCriticalSection(&cs_alloc); +#if _MSC_VER >= 1400 + if (fopen_s(&f, file, "w")) + return; +#else f = fopen(file, "w"); if (!f) - return; + return; +#endif fprintf(f, "Leaked allocations list ....\n"); fprintf(f, "File\tLine\tThread\tSize\n");