/*
* 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.
*/
/*
* Authorization checking:
*
* These functions check 'vntsd' authorization to access guest consoles.
* The mechanism used is Solaris authorizations. The local client (telnet)
* process requesting the connection to a console is verified to have the
* required authorization.
*
* access the consoles of a specific console group. A client connecting to the
* console through telnet must have the appropriate authorization from file
*
* The all-consoles authorization is added during vntsd installation:
* solaris.vntsd.consoles:::Access All LDoms Guest Consoles::
*
* Example of a specific console group authorization based on the name of the
* console group (added manually by a user with 'vntsd.grant' authorization,
* such as 'root'); the group name in this example is "ldg1" :
* solaris.vntsd.console-ldg1:::Access Specific LDoms Guest Console::
*
* Specific users are authorized with usermod(1M). To add an authorization
* logged in):
*
* To authorize a user 'user1' to access all guest consoles:
* # usermod -A solaris.vntsd.consoles user1
*
*/
#include <pwd.h> /* getpw*() */
#include <auth_attr.h> /* chkauthattr() */
#include <secdb.h> /* chkauthattr() */
#include <ucred.h> /* getpeerucred() */
#include <errno.h> /* errno */
/*
* socket_peer_euid()
*
* Return the effective UID (EUID) of the socket peer.
* If none, return -1.
*
* Parameters:
* sock_fd The socket fd of a locally-connected socket (mapped to a pid)
*
* Returns:
* EUID if OK
* -1 on failure or unknown EUID (passed on from ucred_geteuid()).
*/
static uid_t
{
int rc;
/* Get info on the peer on the other side of the socket */
if (rc == -1) {
/* If errno is EINVAL, it's probably a non-local socket peer */
return ((uid_t)-1);
}
/* Extract effective UID (EUID) info for the socket peer process */
/* Return EUID */
return (peer_euid);
}
/*
* auth_check_username()
*
* Check vntsd console authorization, given a user account.
*
* Parameters:
* username The name of a user account to check authorization
* group_name The name of the console group to check authorization. The max
* length of group name is MAXPATHLEN.
*
* Returns:
* 0 if OK (authorized), 1 on authorization failure.
*/
static int
{
int auth_granted = 0;
/* Sanity check: */
return (1); /* error (bad parameter) */
}
/*
* Do authorization checking.
* First, check if the user is authorized access to all consoles. If it
* fails, check authorization to the specific console group.
*/
if (auth_granted)
return (0);
if (auth_granted)
return (0);
return (1);
}
/*
* auth_check_euid()
*
* Check vntsd console authorization, given a EUID.
*
* Parameters:
* euid The effective UID of a user account to check authorization
* group_name The name of the console group to check authorization
*
* Returns:
* 0 if OK (authorized), 1 on authorization failure.
*/
static int
{
/* If EUID is -1, then it's unknown, so fail */
return (1);
}
/* Map EUID to user name */
return (1);
}
/* Do authorization check: */
}
/*
* auth_check_fd()
*
* Check vntsd authorization, given a fd of a socket. The socket fd is mapped
* to a pid (and should not be used for remote connections).
*
* Parameters:
* sock_fd The socket fd of a locally-connected socket (mapped to a pid)
* group_name The name of the console group to check authorization
*
* Returns:
* B_TRUE if OK (authorized), B_FALSE on authorization failure.
*/
{
int rv;
return (B_FALSE);
}
/* Do authorization check: */
if (rv != 0) {
return (B_FALSE);
}
return (B_TRUE);
}