/*
* 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
*/
/*
*/
#include <errno.h>
#include <fcntl.h>
#include <libgen.h>
#include <paths.h>
#include <security/pam_appl.h>
#include <security/pam_modules.h>
#include <security/pam_impl.h>
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
#include <syslog.h>
#include <unistd.h>
/*
* The content of this ticket will be different between 32 bit and 64 bit
* versions of this module. Consideration was given to making it either
* always be 32 bit or always 64 bit but that doesn't solve the problem
* of us having mismatched bit sizes for su and sudo which is the only reason
* for attempting to do this. The module fails safely anyway since
* we explicitly check the file size before reading it, if the file is of
* the wrong size it is unlinked. This will only be visbile to users
* who are running mixed bit size su and sudo alternate between them within
* the lifetime of a single ticket, it will look exactly like a ticket expiry.
*/
struct ticket_content {
};
/*
* This module must only ever return PAM_SUCCESS or PAM_IGNORE, if we
* return PAM_SERVICE_ERR we might stop someone who can authenticate to
* root being able to su to fix any problems. Given that the intent is
* that this module is marked as 'sufficient' in the stack and is always
* above pam_unix_auth.so that is fine.
*/
int
{
int i;
return (PAM_IGNORE);
}
return (PAM_IGNORE);
}
return (PAM_IGNORE);
}
/* Set defaults and set any override options */
for (i = 0; i < argc; i++) {
sizeof ("timeout=") - 1) == 0) {
sizeof ("sudo-compat")) == 0) {
return (PAM_IGNORE);
}
}
}
/* don't use basename() because it modifies its argument */
if (sudo_compat) {
} else {
}
return (PAM_SUCCESS);
}
/*ARGSUSED*/
int
{
int error;
int rb;
if (error != PAM_SUCCESS) {
return (error);
}
error = PAM_IGNORE;
"pam_tty_tickets: unable to stat tty %s: %m\n", tty);
goto out;
}
if (ticket == -1) {
if (debug) {
"pam_tty_tickets: unable to open ticket %s: %m",
}
goto out;
}
if (debug) {
"pam_tty_tickets: unable to stat ticket %s: %m",
}
goto out;
}
if (debug) {
"pam_tty_tickets: invalid ticket %s"
"size got %d expected %d",
sizeof (ticket_content));
}
(void) unlink(ticketname);
goto out;
}
if (rb != sizeof (ticket_content)) {
if (debug) {
"pam_tty_tickets: invalid ticket content %s",
}
goto out;
}
(void) unlink(ticketname);
if (debug) {
"pam_tty_tickets: invalid ticket %s for tty",
ticketname, tty);
}
goto out;
}
(void) unlink(ticketname);
"pam_tty_tickets: ticket %s expired", ticketname);
return (PAM_IGNORE);
}
"pam_tty_tickets: ticket %s valid", ticketname);
error = PAM_SUCCESS;
out:
if (ticket != -1) {
}
return (error);
}
int
{
int wb;
if (error != PAM_SUCCESS) {
return (error);
}
/*
* If we are being asked to delete the creds then we don't
* care if the ticket has expired or if it already existed
* just attempt to remove it.
*/
if (flags & PAM_DELETE_CRED) {
"pam_tty_tickets: deleting ticket %s", ticketname);
(void) unlink(ticketname);
goto out;
}
"pam_tty_tickets: ticket %s still valid", ticketname);
goto out;
}
"pam_tty_tickets: unable to create ticket directory %s",
": %m");
goto out;
}
"pam_tty_tickets: pam_sm_setcred unable to stat tty %s: %m",
tty);
goto out;
}
if (ticket == -1) {
"pam_tty_tickets: unable to create ticket %s: %m",
goto out;
}
if (wb != sizeof (ticket_content)) {
"pam_tty_tickets: unable to create ticket content %s: %m",
(void) unlink(ticketname);
goto out;
}
"pam_tty_tickets: new ticket %s created", ticketname);
error = PAM_SUCCESS;
out:
if (ticket != -1) {
}
}
return (error);
}