/* * resolve * * create a new cache with the name stored in residual */ krb5_error_code KRB5_CALLCONV krb5_stdcc_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 = stdcc_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_open(gCntrlBlock, cName, CC_CRED_V5, 0L, &ccapi_data->NamedCache); if (err != CC_NOERROR) { ccapi_data->NamedCache = NULL; if (err != CC_NO_EXIST) { retval = cc_err_xlate(err); 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; }
static krb5_error_code stdcc_setup(krb5_context context, stdccCacheDataPtr ccapi_data) { int err; /* make sure the API has been intialized */ if (gCntrlBlock == NULL) { #ifdef CC_API_VER2 err = cc_initialize(&gCntrlBlock, CC_API_VER_2, NULL, NULL); #else err = cc_initialize(&gCntrlBlock, CC_API_VER_1, NULL, NULL); #endif if (err != CC_NOERROR) 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_open(gCntrlBlock, ccapi_data->cache_name, CC_CRED_V5, 0L, &ccapi_data->NamedCache); if (err == CC_NOTFOUND) err = CC_NO_EXIST; if (err == CC_NOERROR) return 0; ccapi_data->NamedCache = NULL; return cc_err_xlate(err); }
static void set_compile_options(int argc, char *argv[]) { int count, files = 0; char message[MAX_NAME]; /* AM: the following code is intended to deal with things like */ /* __CLK_TCK (see <time.h>) being different for different targets. */ /* It probably needs better amalgamation into Acorn's code for predefs */ #ifdef TARGET_PREDEFINES { static char *predefs[] = TARGET_PREDEFINES; int i; for (i=0; i < sizeof(predefs)/sizeof(predefs[0]); i++) /* note that the arg may be of the form "name" or "name=toks" */ /* the "name" for is equivalent to "name=1". */ pp_predefine(predefs[i]); } #endif for (count=1; count < argc; ++count) { char *current = argv[count]; if (current[0] == '-' && current[1] != 0) { switch (safe_toupper(current[1])) { case 'C': if (ccom_flags & FLG_PREPROCESS) feature |= FEATURE_PPCOMMENT; else ccom_flags |= FLG_NO_OBJECT_OUTPUT; break; case 'D': pp_predefine(current+2); break; case 'E': /* do we wish to fault -Exxx more generally? */ #ifdef DISABLE_ERRORS if (current[2]) { disable_errors(current+2); break; } #endif #ifdef COMPILING_ON_MVS if (current[2]) { cc_msg( "Obsolete use of '%s' to suppress errors -- use '-zu' for PCC mode\n", current); break; } #endif ccom_flags = (ccom_flags | FLG_PREPROCESS) & ~FLG_COMPILE; break; case 'F': feature_set(current+2); break; #ifdef TARGET_HAS_DEBUGGER case 'G': usrdbg_set(current+2); break; #endif case 'I': set_include_path(current+2, PE_USER); break; case 'J': ccom_flags &= ~FLG_INSTORE_FILES_IMPLICITLY; set_include_path(current+2, PE_SYS); break; case 'K': ccom_flags |= FLG_COUNTS; break; #ifndef NO_LISTING_OUTPUT case 'L': ccom_flags |= FLG_LISTING; listingfile = current + 2; break; #endif case 'M': ccom_flags |= FLG_MAKEFILE; if (current[2] == '<' || current[2] == 0) { ccom_flags &= ~(FLG_COMPILE+FLG_NOSYSINCLUDES); if (current[2] == '<') ccom_flags |= FLG_NOSYSINCLUDES; } else makefile = current+2; break; case 'O': /* * Hum, really we should never get here because this * this should be done by -zpz1. */ break; /* Paranoid define check. Tony 3/1/95 */ #ifdef TARGET_HAS_PROFILE #error Old style define TARGET_HAS_PROFILE (replaced by TARGET_HAS_PROFILER) #endif #ifdef TARGET_HAS_PROFILER case 'P': { int ch = safe_toupper(current[2]); int32 profile = 1L; if (ch == 0) /* do nothing */; else if (ch == 'G' || ch == 'X' && current[3] == 0) profile = 2L; else cc_msg("unknown profile option %s: -p assumed\n",current); var_profile_option = profile; } break; #endif /* TARGET_HAS_PROFILER */ case 'R': #ifdef PASCAL /*ECN*/ rtcheck_set(current+2); #else feature &= ~FEATURE_WR_STR_LITS; #endif break; case 'S': asmfile = current+2; /* "" for -S */ #ifdef COMPILING_ON_MVS /* pesky cc163 compatibility */ if (*asmfile == 0 && count+1<argc) asmfile = argv[++count]; #endif break; #ifdef TARGET_IS_XPUTER case 'T': /* -tn sets processor type == -tn */ pragma_set(current + 1); break; #endif case 'U': pp_preundefine(current+2); break; case 'W': disable_warnings(current+2); break; #ifdef TARGET_IS_MVS /* TARGET_USES_CCOM_INTERFACE ??? */ /* The following case provides -Xcsectname for CC 163 compatibility. */ /* It may be that the CCOM-style interface should stuff ALL unknown */ /* options to mcdep_config_option()? */ case 'X': if (!mcdep_config_option(current[1], current+2)) cc_msg("unknown option %s: ignored\n", current); break; #endif case 'Z': switch(safe_toupper(current[2])) { case 'B': target_lsbitfirst = !target_lsbytefirst; if (isdigit(current[3])) target_lsbitfirst = (current[3]-'0'); break; #ifdef TARGET_ENDIANNESS_CONFIGURABLE case 'E': { int lsbytefirst = current[3] - '0'; if (lsbytefirst) config &= ~CONFIG_BIG_ENDIAN; else config |= CONFIG_BIG_ENDIAN; target_lsbitfirst = lsbytefirst; } break; #endif case 'C': feature |= FEATURE_SIGNED_CHAR; break; case 'F': feature = (feature | FEATURE_FUSSY) & ~FEATURE_LIMITED_PCC; break; case 'I': pre_include(current+3); break; case 'J': config |= CONFIG_INDIRECT_SETJMP; /* related to -fR */ break; case 'P': pragma_set(current+3); break; case 'O': feature |= FEATURE_AOF_AREA_PER_FN; break; case 'Q': debug_set(current+3); break; #ifndef TARGET_IS_HELIOS case 'S': system_flavour = current+3; break; #endif case 'U': feature |= pcc_features(); break; #ifdef TARGET_IS_TRAN /* * Addition to remove C++ warnings (for fussy IGM people). * Tony 8/2/95. */ case 'W': feature |= FEATURE_NO_CPLUSPLUS_WARNINGS; break; #endif /* TARGET_IS_TRAN */ #ifdef PASCAL /*ECN*/ case 'Z': feature |= FEATURE_ISO; break; #endif default: if (!mcdep_config_option(current[2], current+3)) cc_msg("unknown option %s: ignored\n", current); break; } break; default: cc_msg("unknown option %s: ignored\n", current); break; } } else { switch (++files) { case 1: if (strcmp(current, "-") == 0) { /* then just leave as stdin */ #ifdef COMPILING_ON_RISC_OS # ifndef OBSOLETE_ARM_NAMES /* Hack round default no-buffering library. */ setvbuf(stdin, NULL, _IOLBF, 256); # endif #endif } else if (freopen(current,"r",stdin) != NULL) { UnparsedName unparse; char new_dir[MAX_NAME]; ccom_flags &= ~FLG_STDIN; sourcefile = current; /* * Add path name of source file to the -I list. */ translate_fname(current, &unparse, new_dir); new_dir[unparse.un_pathlen] = '\0'; path_hd = mk_path_element(path_hd, PE_USER, new_dir); /* Make sure path_tl is always the tail, even if file precedes -I */ if (path_hd->link == 0) path_tl = path_hd; } else { sprintf(message, "couldn't read file '%s'", current); driver_abort(message); } break; case 2: objectfile = current; break; default: driver_abort("too many file arguments"); } } } if (ccom_flags & FLG_STDIN) { path_hd = mk_path_element(path_hd, PE_USER, ""); if (path_hd->link == 0) path_tl = path_hd; } #ifdef TARGET_HAS_SEPARATE_CODE_DATA_SEGS /* On machines like amd29000 code and data buses are separate */ /* so that all non-instruction data must go in the data segment. */ #if defined TARGET_IS_C40 /* * Ho Hum * * The problem is that programs built with the -Zr option, (such as * the kernel and device drivers), do not have a static data area. * This means that strings MUST be placed into the code segment. BUT * on the C40 data pointers can only address 1/4 of the address map, and * so they may not be able to reach the code segment. (This is especially * true when you consider that the C40 has two address buses, and the plan * is to have data on one bus and code on the other). HENCE by default we * want to disable placing strings in the code segment, but for -Zr programs * we have no choice ... */ if (suppress_module != 1) { feature |= FEATURE_WR_STR_LITS; } else { feature &= ~FEATURE_WR_STR_LITS; } #else feature |= FEATURE_WR_STR_LITS; #endif /* TARGET_IS_C40 */ #endif /* TARGET_HAS_SEPARATE_CODE_DATA_SEGS */ if (ccom_flags & FLG_COMPILE) { /* under the driver.c interface at most one of the following is true */ #ifndef NO_OBJECT_OUTPUT if (objectfile[0] != '\0' && !(ccom_flags & FLG_NO_OBJECT_OUTPUT)) { objstream = cc_open(objectfile, BINARY_FILE); # ifdef COMPILING_ON_RISC_OS set_time_stamp(objectfile, NO); # endif } #endif #ifndef NO_ASSEMBLER_OUTPUT if (asmfile[0] != '\0') asmstream = cc_open(asmfile, TEXT_FILE); #endif if (objectfile[0] == '\0' && asmfile[0] == '\0') { asmstream = stdout; feature |= FEATURE_ANNOTATE; /* simple test use */ } #ifndef NO_LISTING_OUTPUT if (ccom_flags & FLG_LISTING) { if (listingfile[0] != '\0') { listingstream = cc_open(listingfile, TEXT_FILE); if (listingstream != stdout) /* @@@ get rid of this hack */ fprintf(listingstream, " 1 "); } else listingstream = stdout; if (ccom_flags & FLG_COUNTS) { FILE *map = fopen("counts", "rb"); if (map == NULL) driver_abort("couldn't read \"counts\" file"); if (!map_init(map)) driver_abort("malformed \"counts\" file"); } } #endif } if (ccom_flags & FLG_MAKEFILE) { if (makefile[0] == 0) makestream = stdout; else { makestream = cc_open(makefile, TEXT_FILE); } /* * Print out source file and object file for -M option */ fprintf(makestream, DEPEND_FORMAT, objectfile, sourcefile); } }
void main(void) { // XXX (3) - infoNC not properly filled out when returned. infoNC** allCacheInfo = 0; // XXX (2) - bug in krbcc32 infoNC* cacheInfo; ccache_p* theCache = 0; ccache_cit* iterator = 0; cred_union* theCreds = 0; cc_uint32 err; unsigned long index; apiCB* context = 0; // XXX (1) - bug in krbcc32 cc_int32 version; printf ("Dumping all credential caches... (times are in GMT)\n"); err = cc_initialize (&context, CC_API_VER_2, &version, NULL); // XXX (1) if (err != CC_NOERROR) { printf ("*** cc_initialize returned %d ***\n", err); return; } err = cc_get_NC_info (context, &allCacheInfo); // XXX (2) - another bug if (err != CC_NOERROR) { printf ("*** cc_get_NC_info returned %d ***\n", err); return; } for (index = 0; allCacheInfo [index] != 0; index++) { cacheInfo = allCacheInfo [index]; switch (cacheInfo->vers) { case CC_CRED_V4: printf ("\tv4 credentials\n"); break; case CC_CRED_V5: printf ("\tv5 credentials\n"); break; default: printf ("\t*** bogus credentials type %d***\n", cacheInfo->vers); continue; } printf ("\tfor %s\n\tin %s\n", cacheInfo->principal, cacheInfo->name); err = cc_open (context, cacheInfo->name, cacheInfo->vers, 0L, &theCache); if (err != CC_NOERROR) { printf ("\t*** cc_open returned %d ***\n", err); continue; } err = cc_seq_fetch_creds_begin (context, theCache, &iterator); if (err != CC_NOERROR) { printf ("\t*** cc_seq_fetch_creds_begin returned %d ***\n", err); continue; } for (;;) { err = cc_seq_fetch_creds_next (context, &theCreds, iterator); if (err == CC_END) break; if (err != CC_NOERROR) { printf ("\t\t*** seq_fetch_creds returned %d ***\n", err); continue; } switch (theCreds->cred_type) { case CC_CRED_V4: { char start [26]; char end [26]; printf ("\t\t%s - %s: %s.%s@%s\n", datestring (start, theCreds->cred.pV4Cred->issue_date), datestring (end, theCreds->cred.pV4Cred->issue_date + theCreds->cred.pV4Cred->lifetime * 5 * 60), theCreds->cred.pV4Cred->service, theCreds->cred.pV4Cred->service_instance, theCreds->cred.pV4Cred->realm); break; } case CC_CRED_V5: { char start [26]; char end [26]; printf ("\t\t%s - %s: %s\n", datestring (start, theCreds->cred.pV5Cred->starttime), datestring (end, theCreds->cred.pV5Cred->endtime), theCreds->cred.pV5Cred->server); break; } } cc_free_creds (context, &theCreds); } cc_seq_fetch_creds_end (context, &iterator); cc_close (context, &theCache); printf ("\n"); } cc_free_NC_info (context, &allCacheInfo); cc_shutdown (&context); }