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