FreeBSD/usr.sbin/gssd/gssd.c
/*
 * Acquire a gss credential for a uid.
 */
Acquire a gss credential for a uid.
Acquire a gss credential for a uid .
static OM_uint32
gssd_get_user_cred(OM_uint32 *min_statp, uid_t uid, gss_cred_id_t *credp)
{
	gss_buffer_desc principal_desc;
	gss_name_t name;
	OM_uint32 maj_stat, min_stat;
	gss_OID_set mechlist;
	struct passwd *pw;
	pw = getpwuid(uid);
	if (pw == NULL) {
		*min_statp = 0;
		return (GSS_S_FAILURE);
	}
	maj_stat = gss_create_empty_oid_set(min_statp, &mechlist);
	if (maj_stat != GSS_S_COMPLETE)
		return (maj_stat);
	maj_stat = gss_add_oid_set_member(min_statp, GSS_KRB5_MECH_OID_X,
	    &mechlist);
	if (maj_stat != GSS_S_COMPLETE) {
		gss_release_oid_set(&min_stat, &mechlist);
		return (maj_stat);
	}
	principal_desc.value = (void *)pw->pw_name;
	principal_desc.length = strlen(pw->pw_name);
	maj_stat = gss_import_name(min_statp, &principal_desc,
	    GSS_C_NT_USER_NAME, &name);
	if (maj_stat != GSS_S_COMPLETE) {
		gss_release_oid_set(&min_stat, &mechlist);
		return (maj_stat);
	}
	maj_stat = gss_acquire_cred(min_statp, name, 0, mechlist,
	    GSS_C_INITIATE, credp, NULL, NULL);
	gss_release_name(&min_stat, &name);
	gss_release_oid_set(&min_stat, &mechlist);
	return (maj_stat);
}
static OM_uint32 gssd_get_user_cred ( OM_uint32 * min_statp , uid_t uid , gss_cred_id_t * credp ) { gss_buffer_desc principal_desc ; gss_name_t name ; OM_uint32 maj_stat , min_stat ; gss_OID_set mechlist ; struct passwd * pw ; pw = getpwuid ( uid ) ; if ( pw == NULL ) { * min_statp = 0 ; return ( GSS_S_FAILURE ) ; } maj_stat = gss_create_empty_oid_set ( min_statp , & mechlist ) ; if ( maj_stat != GSS_S_COMPLETE ) return ( maj_stat ) ; maj_stat = gss_add_oid_set_member ( min_statp , GSS_KRB5_MECH_OID_X , & mechlist ) ; if ( maj_stat != GSS_S_COMPLETE ) { gss_release_oid_set ( & min_stat , & mechlist ) ; return ( maj_stat ) ; } principal_desc . value = ( void * ) pw -> pw_name ; principal_desc . length = strlen ( pw -> pw_name ) ; maj_stat = gss_import_name ( min_statp , & principal_desc , GSS_C_NT_USER_NAME , & name ) ; if ( maj_stat != GSS_S_COMPLETE ) { gss_release_oid_set ( & min_stat , & mechlist ) ; return ( maj_stat ) ; } maj_stat = gss_acquire_cred ( min_statp , name , 0 , mechlist , GSS_C_INITIATE , credp , NULL , NULL ) ; gss_release_name ( & min_stat , & name ) ; gss_release_oid_set ( & min_stat , & mechlist ) ; return ( maj_stat ) ; }
Acquire a gss credential for a uid.
Acquire a gss credential for a uid .
/*
	 * The mechanism must be set to KerberosV for acquisition
	 * of credentials to work reliably.
	 */ /* Acquire the credentials. */