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