xref: /titanic_44/usr/src/cmd/gss/gssd/gssd_getuid.c (revision 12cc75c814f0c017004a9bbc96429911e008601b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #pragma ident	"%Z%%M%	%I%	%E% SMI"
27 
28 /*
29  *  Routines to set gssd value of uid and replace getuid libsys call.
30  */
31 
32 #include <sys/types.h>
33 #include <unistd.h>
34 #include <stdio.h>
35 #include <stdlib.h>
36 #include <libintl.h>
37 
38 static uid_t krb5_cc_uid;
39 
40 void
41 set_gssd_uid(uid_t uid)
42 {
43 	/*
44 	 * set the value of krb5_cc_uid, so it can be retrieved when
45 	 * app_krb5_user_uid() is called by the underlying mechanism libraries.
46 	 */
47 	printf(gettext("set_gssd_uid called with uid = %d\n"), uid);
48 	krb5_cc_uid = uid;
49 }
50 
51 uid_t
52 app_krb5_user_uid(void)
53 {
54 	/*
55 	 * return the value set when one of the gssd procedures was
56 	 * entered. This is the value of the uid under which the
57 	 * underlying mechanism library must operate in order to
58 	 * get the user's credentials. This call is necessary since
59 	 * gssd runs as root and credentials are many times stored
60 	 * in files and directories specific to the user
61 	 */
62 	printf(gettext(
63 		"getuid called and returning gsssd_uid = %d\n"), krb5_cc_uid);
64 	return (krb5_cc_uid);
65 }
66