/*
* 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 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <assert.h>
#include <priv.h>
#include <pwd.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <unistd.h>
#include <bsm/adt_event.h>
#include "login_audit.h"
/*
* Key assumption: login is single threaded.
*/
static void audit_logout(adt_session_data_t *);
/*
* if audit is not enabled, the adt_*() functions simply return without
* doing anything. In the success case, the credential has already been
* setup with audit data by PAM.
*/
/*
* There is no information passed to login.c from rlogin or telnet
* about the terminal id. They both set the tid before they
* exec login; the value is picked up by adt_start_session() and is
* carefully *not* overwritten by adt_load_hostname().
*/
void
{
int rc;
return;
}
(void) adt_end_session(ah);
return;
}
return;
switch (event_id) {
case ADT_zlogin:
break;
default:
break;
}
(void) adt_free_event(event);
if (rc) {
(void) adt_end_session(ah);
return;
}
/*
* The code above executes whether or not audit is enabled.
* However audit_logout must only execute if audit is
* enabled so we don't fork unnecessarily.
*/
if (adt_audit_enabled()) {
switch (event_id) {
case ADT_login:
case ADT_rlogin:
case ADT_telnet:
case ADT_zlogin:
break;
}
}
(void) adt_end_session(ah);
}
/*
* errors are ignored since there is no action to take on error
*/
static void
{
"adt_alloc_event(ADT_logout): %m");
return;
}
"login audit_logout: could not alloc basic privs: %m");
return;
}
/*
* The child returns and continues the login processing.
* The parent's sole job is to wait for child exit, write the
* logout audit record, and replay the child's exit code.
*/
/* child */
return;
}
if (pid == -1) {
/* failure */
"login audit_logout: could not fork: %m");
return;
}
/* parent process */
/*
* When this routine is called, the current working
* directory is the user's home directory and there are
* unknown open files. For the waiting process, change the
* current directory to root and close files so that the
* user's home directory and anything else can be unmounted
* if necessary.
*/
if (chdir("/") != 0) {
"login audit_logut: could not chdir /: %m");
}
/*
* Reduce privileges to just those needed.
*/
"login audit_logout: could not reduce privs: %m");
}
closefrom(0);
continue;
(void) adt_end_session(ah);
}
/*
* errors are ignored since there is no action to take on error.
*
* If the user id is invalid, pwd is NULL.
*/
void
{
return;
uid = ADT_NO_ATTRIB;
gid = ADT_NO_ATTRIB;
}
/*
* If this is a remote login, in.rlogind or in.telnetd has
* already set the terminal id, in which case
* adt_load_hostname() will use the preset terminal id and
* ignore hostname. (If no remote host and ttyname is NULL,
* let adt_load_ttyname() figure out what to do.)
*/
if (*hostname == '\0')
else
(void) adt_end_session(ah);
return;
}
return;
}
switch (event_id) {
case ADT_zlogin:
break;
}
(void) adt_end_session(ah);
}