/*
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include <stdio.h>
#include <unistd.h>
#include "auditwrite.h"
#include <bsm/audit_kevents.h>
#include <bsm/audit_uevents.h>
#include "dix.h"
#include "misc.h"
#include "scrnintstr.h"
#include "os.h"
#include "regionstr.h"
#include "validate.h"
#include "windowstr.h"
#include "propertyst.h"
#include "input.h"
#include "inputstr.h"
#include "resource.h"
#include "colormapst.h"
#include "cursorstr.h"
#include "dixstruct.h"
#include "selection.h"
#include "gcstruct.h"
#include "servermd.h"
#include <syslog.h>
#include "extnsionst.h"
#include "registry.h"
#include "xace.h"
#include "xacestr.h"
#ifdef PANORAMIX
#include "../Xext/panoramiXsrv.h"
#endif
#include "tsol.h"
#include "tsolinfo.h"
#include "tsolpolicy.h"
/* Unless NO_TSOL_DEBUG_MESSAGES is defined, admins will be able to enable
debugging messages at runtime via Xorg -logverbose */
#ifndef NO_TSOL_DEBUG_MESSAGES
#endif /* NO_TSOL_DEBUG_MESSAGES */
extern int tsol_mac_enabled;
static void
{
}
static void
{
}
/*
* returns
* FALSE - otherwise
*/
{
return TRUE; /* server itself */
}
}
return TRUE;
} else
return FALSE;
}
int
{
/* Check for Trusted Path (TP) */
if (HasTrustedPath(tsolinfo)) {
} else {
goto bad;
}
}
/* Check for Mandatory Access Control (MAC) */
if (flags & TSOL_READOP) {
reqcode != X_GetImage) ||
((flags & TSOL_DOMINATE) &&
} else {
goto bad;
}
}
if (flags & TSOL_WRITEOP) {
} else {
goto bad;
}
}
}
/* Check for Discretionary Access Control (DAC) */
if (flags & TSOL_READOP) {
/* ((tsolres->uid == OwnerUID || tsolres->uid == DEF_UID) && */
} else {
goto bad;
}
}
if (flags & TSOL_WRITEOP) {
reqcode == X_ChangeWindowAttributes) ||
} else {
goto bad;
}
}
}
return Success;
bad:
/* Access denied */
"tsol_check_policy(%s, %s, %d, pid=%d, %s, %d, %s) = %s\n",
"BadAccess");
return BadAccess;
}
#ifndef NO_TSOL_DEBUG_MESSAGES
/*
* Converts SL to string
*/
static char *
{
return (NULL);
else
return slstring;
}
#endif /* !NO_TSOL_DEBUG_MESSAGES */
/*
* Allocate a single privilege set
*/
static priv_set_t *
{
perror("priv_allocset");
FatalError("Cannot allocate privilege set");
}
return pset;
}
/*
* Initialize all string window privileges to the binary equivalent.
* Binary privilege testing is much faster than the string testing
*/
void
init_win_privsets(void)
{
}
void
free_win_privsets(void)
{
}
int
{
}
void
{
int obj_code;
int status;
int err_code;
int reqtype;
if (client->requestBuffer) {
} else {
reqtype = -1;
}
switch (rtype) {
case RT_WINDOW:
break;
case RT_PIXMAP:
break;
}
/* Ignore unlabeled resources */
}
switch (reqtype) {
case X_GetImage:
case X_CopyArea:
case X_CopyPlane:
/*
* Image operations are allowed here for lookup reasons.
* The actual policy enforcement is in the protocol handler.
*/
if (check_mode & DixReadAccess) {
check_mode &= ~DixReadAccess;
}
break;
case X_ClearArea:
if (check_mode & DixWriteAccess) {
check_mode &= ~DixWriteAccess;
}
break;
case X_GrabPointer:
case X_UngrabPointer:
case X_GrabKeyboard:
case X_UngrabKeyboard:
case X_GrabKey:
case X_UngrabKey:
case X_GrabButton:
case X_UngrabButton:
case X_WarpPointer:
/*
* Allow pointer grab on root window, as long as
* pointer is currently in a window owned by
* requesting client.
*/
if (WindowIsRoot(pWin)) {
}
break;
case X_ChangeSaveSet:
if (check_mode & modes) {
if (priv_win_config ||
}
check_mode &= ~modes;
}
break;
}
{
check_mode &= ~modes;
}
}
/* Newly created drawable. Initialize it. */
if (check_mode & DixCreateAccess) {
check_mode &= ~(DixCreateAccess);
}
if (check_mode & modes) {
if (reqtype == X_GetInputFocus)
flags |= TSOL_DOMINATE;
check_mode &= ~modes;
}
if (check_mode & modes) {
check_mode &= ~modes;
}
/* Event access, actual policy is implemented in the hook */
if (check_mode & modes) {
check_mode &= ~modes;
}
}
}
else
#ifndef NO_TSOL_DEBUG_MESSAGES
if (check_mode) { /* Any access mode bits not yet handled ? */
"policy not implemented for TsolCheckWindowAccess, "
"rtype=0x%x (%s), mode=0x%x (%s)\n",
}
"TsolCheckDrawableAccess(%s, %s, 0x%x, %s, %s) = %s\n",
}
#endif /* !NO_TSOL_DEBUG_MESSAGES */
}
void
{
int object_code;
int err_code;
int reqtype;
if (client->requestBuffer) {
} else {
reqtype = -1;
}
switch (rtype) {
case RT_FONT:
break;
case RT_GC:
break;
case RT_CURSOR:
break;
case RT_COLORMAP:
break;
default:
break;
}
/* Anyone can create an object */
if (check_mode & DixCreateAccess) {
}
/* DAC check is based on client isolation */
if (check_mode & modes) {
}
check_mode &= ~modes;
}
if (check_mode & modes) {
}
check_mode &= ~modes;
}
}
#ifndef NO_TSOL_DEBUG_MESSAGES
if (check_mode) { /* Any access mode bits not yet handled ? */
"policy not implemented for TsolCheckXIDAccess, "
"rtype=0x%x (%s), mode=0x%x (%s)\n",
}
"TsolCheckXIDAccess(%s, %s, 0x%x, %s, %s) = %s\n",
}
#endif /* !NO_TSOL_DEBUG_MESSAGES */
}
void
{
int object_code = 0;
int reqtype;
if (client->requestBuffer) {
} else {
reqtype = -1;
}
/* rec->status = Success; return; */
modes = (DixManageAccess);
if (check_mode & modes) {
switch (reqtype) {
case X_SetFontPath:
if (priv_win_fontpath ||
}
break;
case X_ChangeHosts:
case X_SetAccessControl:
if (priv_win_config ||
pset_win_config)) {
}
break;
}
check_mode &= ~modes;
}
}
if (check_mode & modes) {
check_mode &= ~modes;
}
#ifndef NO_TSOL_DEBUG_MESSAGES
if (check_mode) { /* Any access mode bits not yet handled ? */
"policy not implemented for TsolCheckServerAccess, "
"mode=0x%x (%s)\n",
}
"TsolCheckServerAccess(%s, %s, %s) = %s\n",
}
#endif /* !NO_TSOL_DEBUG_MESSAGES */
}
void
{
int reqtype;
if (client->requestBuffer) {
} else {
reqtype = -1;
}
if (check_mode & modes) {
if (priv_win_config ||
}
check_mode &= ~modes;
}
}
#ifndef NO_TSOL_DEBUG_MESSAGES
if (check_mode) { /* Any access mode bits not yet handled ? */
"policy not implemented for TsolCheckClientAccess, "
"mode=0x%x (%s)\n",
}
"TsolCheckClientAccess(%s, %s, %s) = %s\n",
}
#endif /* !NO_TSOL_DEBUG_MESSAGES */
}
void
{
int reqtype;
if (client->requestBuffer) {
} else {
reqtype = -1;
}
/* Allow all device access to the server itself */
if (client == serverClient) {
check_mode = 0;
}
if (check_mode & modes) {
check_mode &= ~modes;
}
if (check_mode & modes) {
if (priv_win_devices ||
}
check_mode &= ~modes;
}
#ifndef NO_TSOL_DEBUG_MESSAGES
if (check_mode) { /* Any access mode bits not yet handled ? */
"policy not implemented for TsolCheckDeviceAccess, %s, %s\n",
}
"TsolCheckDeviceAccess(%s, %s, %s) = %s\n",
}
#endif /* !NO_TSOL_DEBUG_MESSAGES */
}
{
int rc;
}
{
}
return tsolres;
}