1 #pragma ident "%Z%%M% %I% %E% SMI" 2 3 /* 4 * lib/krb5/os/realm_dom.c 5 * 6 * Copyright 1990,1991 by the Massachusetts Institute of Technology. 7 * All Rights Reserved. 8 * 9 * Export of this software from the United States of America may 10 * require a specific license from the United States Government. 11 * It is the responsibility of any person or organization contemplating 12 * export to obtain such a license before exporting. 13 * 14 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and 15 * distribute this software and its documentation for any purpose and 16 * without fee is hereby granted, provided that the above copyright 17 * notice appear in all copies and that both that copyright notice and 18 * this permission notice appear in supporting documentation, and that 19 * the name of M.I.T. not be used in advertising or publicity pertaining 20 * to distribution of the software without specific, written prior 21 * permission. Furthermore if you modify this software you must label 22 * your software as modified software and not distribute it in such a 23 * fashion that it might be confused with the original M.I.T. software. 24 * M.I.T. makes no representations about the suitability of 25 * this software for any purpose. It is provided "as is" without express 26 * or implied warranty. 27 * 28 * 29 * krb5_get_realm_domain() 30 */ 31 32 33 /* 34 * Determines the proper domain name for a realm. This is mainly so that 35 * a krb4 principal can be converted properly into a krb5 principal. 36 * Currently, the same style of mapping file used in krb4. 37 * 38 * If realm is NULL, this function will assume the default realm 39 * of the local host. 40 * 41 * The returned domain is allocated, and must be freed by the caller. 42 * 43 * This was hacked together from krb5_get_host_realm(). 44 */ 45 46 #include "k5-int.h" 47 #include <ctype.h> 48 #include <stdio.h> 49 50 krb5_error_code KRB5_CALLCONV 51 krb5_get_realm_domain(krb5_context context, const char *realm, char **domain) 52 { 53 krb5_error_code retval; 54 char *temp_domain = 0; 55 56 retval = profile_get_string(context->profile, "realms", realm, 57 "default_domain", realm, &temp_domain); 58 if (!retval && temp_domain) 59 { 60 *domain = malloc(strlen(temp_domain) + 1); 61 if (!*domain) { 62 retval = ENOMEM; 63 } else { 64 strcpy(*domain, temp_domain); 65 } 66 profile_release_string(temp_domain); 67 } 68 return retval; 69 } 70