/*
* 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.
*/
#include <security/pam_appl.h>
#include <pwd.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
#include <unistd.h>
#include <ctype.h>
#include <syslog.h>
#include <errno.h>
#include "utils.h"
extern const char *error_message(long);
/* ******************************************************************** */
/* */
/* Utilities Functions */
/* */
/* ******************************************************************** */
/*
* get_pw_uid():
* To get the uid from the passwd entry for specified user
* It returns 0 if the user can't be found, otherwise returns 1.
*/
int
{
return (0);
}
return (1);
}
/*
* get_pw_gid():
* To get the gid from the passwd entry for specified user
* It returns 0 if the user can't be found, otherwise returns 1.
*/
int
{
return (0);
}
return (1);
}
/*
* get_kmd_kuser():
* To get the kerberos user name for the specified user.
* Assumes that the kuser string is allocated. It will be
* overwritten. This saves us having to deal will allocating
* and freeing the kuser string.
*
* RFC 1510 does not mention how to handle mixed case domainnames
* while constructing client principals. So we will follow the same
* procedure as for server principals and lowercase the domainname.
*
* Returns:
* PAM_BUF_ERR - if there is an error from krb5_sname_to_principal(),
* or krb5_unparse_name()
* 0 - if there was no error
*/
int
{
KRB5_NT_SRV_HST, &princ)) {
return (PAM_BUF_ERR);
}
return (PAM_BUF_ERR);
}
/* just interested in princ name before the @REALM part */
return (PAM_BUF_ERR);
}
return (PAM_BUF_ERR);
}
} else {
return (PAM_BUF_ERR);
}
}
return (0);
}
/*
* return true (1) if the user's key is in the (default) keytab
*/
int
{
if (debug)
"PAM-KRB5 (%s): start for user '%s'",
if (!user)
return (retval);
/* need to free context with krb5_free_context */
if (debug)
"PAM-KRB5 (%s): Error initializing "
"krb5: %s", whoami,
return (retval);
}
2*MAXHOSTNAMELEN)) != 0) {
goto out;
}
/* need to free princ with krb5_free_principal */
if (debug)
"PAM-KRB5 (%s): can't parse name (%s)",
goto out;
}
/* need to close keytab handle with krb5_kt_close */
if (debug)
"PAM-KRB5 (%s): krb5_kt_default failed (%s)",
goto out;
}
if (code != 0) {
if (debug)
"PAM-KRB5 (%s): "
"Keytab does not exist",
whoami);
} else if (code == KRB5_KT_NOTFOUND) {
if (debug)
"PAM-KRB5 (%s): "
"No entry for principal "
"'%s' exists in keytab",
} else {
if (debug)
"PAM-KRB5 (%s): "
"krb5_kt_get_entry failed (%s)",
}
} else { /* Key found in keytab, return success */
if (debug)
"PAM-KRB5 (%s): "
"keytab entry for '%s' found",
retval = 1;
}
out:
if (kcontext)
return (retval);
}