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
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.
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]
22 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
25 * Copyright (c) 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T
28 * Portions of this source code were derived from Berkeley
29 * 4.3 BSD under license from the Regents of the University of
33 #pragma ident "%Z%%M% %I% %E% SMI"
34 /* from kerbd_handle.c 1.3 92/01/29 SMI */
37 * gssd_handle.c, Interface to gssd
46 #include <netconfig.h>
47 #include <sys/utsname.h>
51 #define dprt(msg) (void) fprintf(stderr, "%s\n", msg);
58 * Keep the handle cached. This call may be made quite often.
65 struct netconfig
*nconf
;
66 struct netconfig
*tpconf
;
68 struct timeval wait_time
;
70 static char *hostname
;
71 static bool_t first_time
= TRUE
;
73 #define TOTAL_TIMEOUT 1000 /* total timeout talking to gssd */
74 #define TOTAL_TRIES 1 /* Number of tries */
78 if (!(localhandle
= setnetconfig()))
81 if (first_time
== TRUE
) {
83 return ((CLIENT
*) NULL
);
84 if ((hostname
= strdup(u
.nodename
)) == (char *)NULL
)
85 return ((CLIENT
*) NULL
);
88 while (nconf
= getnetconfig(localhandle
)) {
89 if (strcmp(nconf
->nc_protofmly
, NC_LOOPBACK
) == 0) {
90 if (nconf
->nc_semantics
== NC_TPI_COTS_ORD
) {
91 clnt
= clnt_tp_create(hostname
,
92 GSSPROG
, GSSVERS
, nconf
);
94 dprt("got COTS_ORD\n");
102 if ((clnt
== NULL
) && (tpconf
)) {
104 /* Now, try the connection-oriented loopback transport */
106 clnt
= clnt_tp_create(hostname
, GSSPROG
, GSSVERS
, tpconf
);
113 endnetconfig(localhandle
);
116 * This bit of code uses an as yet unimplemented argument to
117 * clnt_control(). CLSET_SVC_PRIV specifies that the underlying
118 * loopback transport should be checked to ensure it is
119 * connected to a process running as root. If so, the clnt_control()
120 * call returns TRUE. If not, it returns FALSE.
123 #ifdef CLSET_SVC_PRIV
125 if (clnt_control(clnt
, CLSET_SVC_PRIV
, NULL
) != TRUE
) {
134 clnt
->cl_auth
= authsys_create("", getuid(), 0, 0, NULL
);
135 if (clnt
->cl_auth
== NULL
) {
140 wait_time
.tv_sec
= TOTAL_TIMEOUT
/TOTAL_TRIES
;
141 wait_time
.tv_usec
= 0;
142 (void) clnt_control(clnt
, CLSET_RETRY_TIMEOUT
, (char *)&wait_time
);