/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* This contains miscellaneous functions moved from commands to the library.
*/
#include "mt.h"
#include <stdlib.h>
#include <stdio.h>
#include <syslog.h>
#include <string.h>
#include <unistd.h>
#include <rpcsvc/nis_dhext.h>
#include <rpc/auth_sys.h>
#include <rpc/auth_des.h>
#include <rpc/key_prot.h>
#include <netdir.h>
#include <netconfig.h>
#include <netdb.h>
#include <dlfcn.h>
#ifdef _LP64
#else /* _LP64 */
#endif /* _LP64 */
9, "\053\006\004\001\052\002\032\001\001"
};
/*
* gss_OID_load()
*
* This routine is called by __nis_gssprin2netname to define values for
* the gss-api-export-name OID, the Diffie-Hellman netname OID, and
* the gss support routines that it needs.
* The reason for this support routine is that libnsl cannot have an
* explicit dependency on libgss. Callers of __nisgssprin2netname are
* expected to have loaded libgss through the rpcsec layer. The work around
* is to dlopen the needed shared objects and grab the symbols with dlsym.
* This routine opens libgss RTLD_NOLOAD. If this fails then libgss.so.1
* is not loaded and we return error. Otherwise it uses dlsym to
* defines GSS_EXPORT_NAME to have the value of GSS_C_NT_EXPORT_NAME and
* to assign the above fuction pointers.
* If this succeeds then the routine will attempt to load mech_dh.so.1
* and over ride DH_NETNAME with the value of __DH_GSS_C_NT_NETNAME from
* that shared object. We don't consider it an error if this fails because
* its conceivable that another mechanism backend will support the netname
* name type and mech_dh.so.1 not be available.
*
* Return 0 on failer, 1 on success.
*/
static int
{
void *dh;
int stat = 0;
(void) mutex_lock(&gss_load_lock);
if (GSS_EXPORT_NAME) {
(void) mutex_unlock(&gss_load_lock);
return (0);
}
/* if LIBGSS is not loaded return an error */
(void) mutex_unlock(&gss_load_lock);
return (0);
}
if (OIDptr)
else
goto Done;
if (g_import_name == 0)
goto Done;
if (g_display_name == 0)
goto Done;
if (g_release_name == 0)
goto Done;
if (g_release_buffer == 0)
goto Done;
if (g_release_oid == 0)
goto Done;
stat = 1;
/*
* Try and get the official netname oid from mech_dh.so.
* If this fails will just keep our default from above.
*/
if (OIDptr)
DH_NETNAME = *OIDptr;
}
Done:
(void) mutex_unlock(&gss_load_lock);
if (stat == 0)
GSS_EXPORT_NAME = 0;
return (stat);
}
/*
* int
* __nis_gssprin2netname(rpc_gss_principal_t prin,
* char netname[MAXNETNAMELEN+1])
*
* This routine attempts to extract the netname from an rpc_gss_principal_t
* which is in { gss-api-exorted-name } format. Return 0 if a netname was
* found, else return -1.
*/
/*
* This routine has a dependency on libgss.so. So we will pragma weak
* the interfaces that we need. When this routine is called libgss
* should have been loaded by the rpcsec layer. We will call gss_OID_load
* to get the value for GSS_EXPORT_NAME. If gss_OID_load failes return -1.
*/
int
{
/* See if we already got the OID */
if (GSS_EXPORT_NAME == 0) {
/* Nope. See if GSS is loaded and get the OIDs */
if (!gss_OID_load())
return (-1); /* if libgss.so.1 isn't loaded */
}
if (major == GSS_S_COMPLETE) {
&display_name, &name_type);
/* We're done with the gss_internal name */
if (major == GSS_S_COMPLETE) {
/*
* Check if we've got a netname. If we do we copy it
* and make sure that its null terminated.
*/
(char *)display_name.value,
stat = 0;
}
/*
* If there are other display formats that can
* be converted to netnames easily, insert here.
*
* else if (OID_IS_EQUAL(OTHER_NT_OID, name_type)) {
* convert2netname(display_name.value, netname);
* } ...
*/
/* Release temporty storage */
}
}
if (stat == 0)
return (stat);
return (stat);
}
/*
* Extract a public key given a key length and alg. type from a packed
* netobj containing extended Diffie-Hellman keys.
*/
char *
{
char *hexkey;
/* LINTED pointer cast */
/* LINTED pointer cast */
char *keyoffset;
return (NULL);
return (hexkey);
}
/* LINTED pointer cast */
}
return (NULL);
}