tsolutils.c revision 196
/* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
*
* 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,
* to whom the Software is furnished to do so, provided that the above
* copyright notice(s) and this permission notice appear in all copies of
* the Software and that both the above copyright notice(s) and this
* permission notice appear in supporting documentation.
*
* 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
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
* INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
* Except as contained in this notice, the name of a copyright holder
* shall not be used in advertising or otherwise to promote the sale, use
* or other dealings in this Software without prior written authorization
* of the copyright holder.
*/
#pragma ident "@(#)tsolutils.c 1.15 07/04/03 SMI"
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#define NEED_EVENTS
#include <stdio.h>
#include <X11/Xprotostr.h>
#include "auditwrite.h"
#include <bsm/audit_uevents.h>
#include <regex.h>
#include <priv.h>
#include "windowstr.h"
#include "scrnintstr.h"
#include "tsolinfo.h"
#include "misc.h"
#include "inputstr.h"
#include "propertyst.h"
#define MAX_SL_ENTRY 256
#define MAX_UID_ENTRY 64
#define ALLOCATED 1
#define EMPTIED 0
#define FamilyTSOL 5
#define TSOLUIDlength 4
FALSE };
/*
* The following need to be moved to tsolextension.c
* after all references in Xsun is pulled out
*/
#define TsolMaxPolyNameSize 80
/*
* Use the NodeRec struct in tsolinfo.h. This is referenced
* in policy routines. So we had to move it there
*/
/*
* Private indices
*/
int tsolClientPrivateIndex = -1;
int tsolWindowPrivateIndex = -1;
int tsolPixmapPrivateIndex = -1;
unsigned int StripeHeight = 0;
int tsol_nodelength = 0;
extern int PanoramiXPixHeight;
/* This structure is used for protocol request ListHosts */
struct xUIDreply
{
unsigned char family;
unsigned char pad;
unsigned short length;
int uid; /* uid type */
};
struct slentry
{
char allocated;
};
/* This table contains list of users who can connect to the server */
struct uidentry
{
int userid; /* uid type */
char allocated;
};
/* Index must match with keywords */
"extension", "privilege"};
#define KEYWORDCOUNT sizeof(tsolconfig_keywords)/sizeof(char *)
typedef struct _TsolConfig
{
int count;
char **list;
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL},
{0, NULL}
};
#define TSOL_ATOMCOUNT 4
static char *tsolatomnames[TSOL_ATOMCOUNT] = {
"_TSOL_CMWLABEL_CHANGE",
"_TSOL_GRABNOTIFY",
"_TSOL_CLIENT_TERM",
"_TSOL_SEL_AGNT"
};
#ifdef DEBUG
/*
* selectively enable debugging. upto 32 levels of debugging supported
* flags are defined in tsolinfo.h
*/
unsigned long tsoldebug = 0; /* TSOLD_SELECTION; */
#endif /* DEBUG */
void
{
}
/* Initialize UID table, this table should at least contains owner UID */
void
{
}
/* Count how many valid entried in the uid table */
int
{
int i, count = 0;
/* Search entire table */
for (i = 0; i < MAX_UID_ENTRY; i++)
{
count++;
}
return (count);
}
/* return (1); if userid is in the table */
int
int userid;
{
int i;
for (i = 0; i < MAX_UID_ENTRY; i++)
{
{
return (1); /* yes, found it */
}
}
return (0); /* not found */
}
/* Passed into a pointer to a storage which is used to store UID */
/* and nUid represents how many UID in the table(returned by count_uid_table) */
int
int nUid;
{
int i, j = 0;
for (i = 0; i < MAX_UID_ENTRY; i++)
{
{
j++;
}
}
if (nUid != j)
{
ErrorF("Invalid no. of uid entries? \n");
return (0);
}
return (1);
}
/* add userid into UIDtable */
int
int *userid;
{
int i = 0;
/*
* Search entire uidtable, to prevent duplicate uid
* entry in the table
*/
while (i < MAX_UID_ENTRY)
{
{
/* this uid entry is already in the table; no-op */
return (1); /* Success, uid in the table */
}
i++;
}
i = 0;
/*
* If we can find an empty entry, then add this uid
* into the table
*/
while (i < MAX_UID_ENTRY)
{
{
return (1); /* Success, uid in the table */
}
i++;
}
/* uidtable overflow */
ErrorF("Server problem: Please enlarge the table size of uidtable \n");
return (0);
}
/* remove userid from UIDtable */
int
int *userid;
{
int i = 0;
if (*userid == 0)
{
ErrorF("\n UID 0 can not be removed from server UID list");
return (0);
}
while (i < MAX_UID_ENTRY)
{
{
/* delete this entry in the table */
return (1); /* Success, uid in the table */
}
i++;
}
/* no such entry in the table, why delete it? no-op */
return (0);
}
{
}
{
int i = 0;
return (slptr);
{
{
/* found a matching sensitivity label in sltable */
}
i++;
}
if (i < MAX_SL_ENTRY)
{
/*
* can't find a matching entry in sltable,
* however, we have empty entry to store this
* new sensitivity label; store it.
*/
}
/*
* no matching entry in sltable, and no room to
* store this new sensitivity label,
* the server needs to recomplie with a larger slabel
*/
ErrorF("Server problem: Please enlarge the table size of sltable \n");
return (0);
}
int
int screen_num;
{
extern char *ConnectionInfo;
extern int connBlockScreenStart;
int i, j;
int old_height;
float height_mult;
for (i = 0; i < screen_num; i++)
{
{
}
}
if (noPanoramiXExtension)
{
} else
{
}
/* compute new millimeter height */
return (0);
}
void
{
extern Bool system_audit_on;
extern bslabel_t PublicObjSL;
extern int cannot_audit(int); /* bsm function */
if (cannot_audit(TRUE))
else
}
/*
* Converts keycode to keysym, helper function.
* Modelled after Xlib code
*/
static KeySym
{
return NoSymbol;
if (col < 4) {
if (col > 1) {
per--;
if (per < 3)
col -= 2;
}
if (!(col & 1))
return lsym;
return NoSymbol;
else
return usym;
}
}
}
/*
* Converts keysym to a keycode
* Modelled after Xlib code
*/
static KeyCode
{
int i, j;
for (j = 0; j < curKeySyms->mapWidth; j++) {
return i;
}
}
return 0;
}
/*
* converts a keysym to modifier equivalent mask
* Modelled after Xlib
*/
static unsigned
{
KeySym *k;
mods = 0;
while (k < kmax) {
if (*k == ks ) {
while (--j >= 0) {
}
}
k++;
}
return mods;
}
/*
* Initialize Hot Key keys. On A Sun type 5/6 keyboard
* It's Meta(Diamond) + Stop. On a non-Sun keyboard, it's
* Alt + Break(Pause) key. Hold down the meta or alt key
* press stop or break key.
*
* NOTE:
* Both Left & Right keys for (Meta or Alt) return the
* same modifier mask
*/
void
{
/* Meta + Stop */
}
void
{
int i;
int count;
char **newlist;
return; /* ignore incomplete entries */
/* find a matching keyword */
for (i = 0; i < KEYWORDCOUNT; i++) {
break;
}
}
/* Invalid keyword */
if (i >= KEYWORDCOUNT) {
return;
}
return;
}
tsolconfig[i].count++;
}
void
{
int i;
int count;
char **list;
for (i = 0; i < count; i++) {
priv_win_dga = TRUE;
}
}
/*
* Load Trusted Solaris configuration file
* TBD: Process extension keywords
*/
void
{
char *keyword;
char *value;
/* open the file from /etc first followed by /usr */
ErrorF("Cannot load %s. Some desktop applications may not\n"
"work correctly\n", TSOLPOLICYFILE);
return;
}
/* Read and parse the config file */
/* ignore all comments, lines starting with white space */
continue;
}
}
/*
* It does not really tell if this atom is to be polyinstantiated
* or not. Further check should be done to determine this.
*/
int
{
}
void
{
int i;
char *atomname;
Atom a;
/* Create new TSOL atoms */
for (i = 0; i < TSOL_ATOMCOUNT; i++) {
AtomError();
}
/* Create atoms defined in config file */
AtomError();
}
}
}
/*
* Names starting with a slash in selection.atoms and property.atoms
* are treated as regular expressions to be matched against the
* selection and property names. They may optionally end with a slash.
*/
int
{
int status;
char *regexpstrp;
int regexpstrlen;
/* Extract regular expression from between slashes */
/* Compile the regular expression */
if (status == 0) {
/* Make null-terminated copy of string */
/* Compare string to regular expression */
if (status == 0)
return (TRUE);
else
return (FALSE);
}
return (TRUE);
}
return (FALSE);
}
int
{
int i;
int count;
char **list;
unsigned int flags = 0;
for (i = 0; i < count; i++) {
flags |= TSOLM_PROPERTY;
break;
}
}
for (i = 0; i < count; i++) {
flags |= TSOLM_SELECTION;
break;
}
}
return (flags);
}
{
}
/* Property is polyinstantiated only on root window */
int
{
if (WindowIsRoot(pWin) &&
return TRUE;
return FALSE;
}
int
{
return TRUE;
return FALSE;
}
/*
* Returns true if a matching sl.uid pair found. Must be applied
* only to polyprops.
*/
int
{
while (tsolprop)
{
if (tsolpolyinstinfo.enabled)
{
return TRUE;
}
else
{
return TRUE;
}
}
return FALSE;
}
/*
* client or is a default server xid
*/
int
{
return TRUE;
else
return FALSE;
}
/*
* Same as TopClientWin()
* except that it returns a Window ID
* and not a ptr
*/
{
if (pWin)
{
}
return (NULL);
}
/*
* Return root window of pWin
*/
{
if (pWin)
{
}
return (pWin);
}
{
if (pWin)
{
}
return (NULL);
}
/*
* client
*/
int
{
return FALSE;
if((SERVER_BIT & xid) == 0)
{
return TRUE;
{
return TRUE;
}
}
return FALSE;
}
{
{
{
#ifdef SHAPE
#endif
)
return(pSib);
}
}
}
/*
* Return Top level client window of pWin
*/
{
if (pWin)
{
{
break;
}
}
return (pWin);
}
/*
* returns the window under pointer. This is function because
* sprite is static & TsolPointerWindow is called in policy functions.
*/
{
return (GetSpriteWindow()); /* Window currently under mouse */
}
/*
* Matches in the list of disabled extensions via
* the policy file (TrustedExtensionsPolicy)
* Returns
* TRUE - if a match is found
* FALSE - otherwise
*/
int
{
int i;
return TRUE;
}
}
return FALSE;
}