tsolextension.c revision 679
606N/A/* Copyright 2009 Sun Microsystems, Inc. All rights reserved. 0N/A * Permission is hereby granted, free of charge, to any person obtaining a 0N/A * copy of this software and associated documentation files (the 0N/A * "Software"), to deal in the Software without restriction, including 0N/A * without limitation the rights to use, copy, modify, merge, publish, 0N/A * distribute, and/or sell copies of the Software, and to permit persons 0N/A * to whom the Software is furnished to do so, provided that the above 0N/A * copyright notice(s) and this permission notice appear in all copies of 0N/A * the Software and that both the above copyright notice(s) and this 0N/A * permission notice appear in supporting documentation. 0N/A * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 0N/A * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 0N/A * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 0N/A * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 0N/A * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL 0N/A * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING 0N/A * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 0N/A * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 0N/A * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 0N/A * Except as contained in this notice, the name of a copyright holder 0N/A * shall not be used in advertising or otherwise to promote the sale, use 0N/A * or other dealings in this Software without prior written authorization 0N/A * of the copyright holder. 606N/A/* XACE hook callbacks */ 0N/A * Initialize the extension. Main entry point for this loadable 228N/A /* This extension is supported on a labeled system */ 0N/A ErrorF(
"TsolExtensionInit: AddExtension failed for X Trusted Extensions\n");
606N/A /* Allocate storage in devPrivates */ 606N/A ErrorF(
"TsolExtensionInit: Cannot allocate devPrivate.\n");
679N/A /* Initialize the client info for server itself */ 606N/A /* Initialize security hooks */ 606N/A tsolSecHook.DeleteClientFromAnySelections = TsolDeleteClientFromAnySelections; 606N/A tsolSecHook.DeleteWindowFromAnySelections = TsolDeleteWindowFromAnySelections; 0N/A /* Save original Proc vectors */ 0N/A /* Replace some of the original Proc vectors with our own TBD */ 679N/A /* ProcVector[X_GetImage] = ProcTsolGetImage; */ 679N/A /* CreateWindow, policy check on the parent */ 679N/A /* Newly created window. Just initialize it. */ 679N/A /* Event access, actual policy is implemented in the hook */ 679N/A /* Property related access */ 606N/A /* The rest falls through to code shared with RT_PIXMAP */ 0N/A /* Drawing operations use pixel access policy */ 679N/A /* Newly created window. Just initialize it. */ 679N/A CHECK_RESOURCE_POLICY(DixReadAccess, 679N/A TSOL_RES_PIXMAP, TSOL_READ, rval, 0); 679N/A CHECK_RESOURCE_POLICY(DixWriteAccess, 679N/A TSOL_RES_PIXMAP, TSOL_MODIFY, rval, 0); 639N/A "policy not implemented for CheckResourceAccess, " 639N/A "rtype=0x%x (%s), mode=0x%x (%s)\n",
639N/A#
endif /* !NO_TSOL_DEBUG_MESSAGES */ 639N/A /* rest of the function is just printing error or debug messages */ 639N/A /* Trace messages for debugging */ 639N/A#
endif /* NO_TSOL_DEBUG_MESSAGES */ 639N/A "CheckResourceAccess(%s, %s, 0x%x, %s, %s) = %s\n",
679N/A /* fall through to reset the SL */ 679N/A /* All others handled in SelectionAccess handler */ 0N/A /* Got a new connection */ 36N/A /* Audit disconnect */ 0N/A * Individual routines 606N/A * Set PolyInstantiation Info. 0N/A * Normally a get(prop) will 0N/A * get the prop. that has match sl, uid of the client. Setting 0N/A * enabled to true will get only the prop. corresponding to 0N/A * sl, uid specified instead of that of client. This is used 0N/A * Check for policy here 0N/A /* first see if property already exists */ 0N/A /* property does not exist */ 168N/A /* Initialize property created internally by server */ 0N/A /* first see if property already exists */ 0N/A /* property does not exist */ 168N/A /* Initialize property created internally by server */ 0N/A /* generate the notify event for windows */ 0N/A /* set Screen Stripe Size */ 0N/A /* Valid window check */ 0N/A /* Transfer the client info to reply rec */ 0N/A /* Valid window check */ 0N/A /* Transfer the client info to reply rec */ 0N/A /* allocate temp storage for labels */ 0N/A /* fill the fields as per request mask */ 0N/A /* first see if property already exists */ 679N/A break;
/* match found */ 679N/A break;
/* match found */ 679N/A /* property does not exist, use window's attributes */ 0N/A /* allocate temp storage for labels */ 0N/A /* fill the fields as per request mask */ 0N/A /* allocate temp storage for labels */ 0N/A /* fill the fields as per request mask */ 606N/A * Session type single-level? This is set by the 470N/A /* window should not be root but child of root */ 311N/A /* window should not be root but child of root */ 0N/A * Force kbd & ptr ungrab. This will cause 0N/A * screen to lock even when kbd/ptr grabbed by 0N/A * Turn on window's Trusted bit 0N/A /* window should not be root but child of root */ 0N/A /* Turn on Trusted bit of the window */ 0N/A * Turn off window's Trusted bit 0N/A /* window should not be root but child of root */ 0N/A * Break keyboard & ptr grabs of clients other than 0N/A * the requesting client. 0N/A * Called from ProcMakeTPWindow. 0N/A * Trusted Network interface module. Uses tsix API 0N/A /* Get client attributes from the socket */ 639N/A " for %s, getpeerucred failed: %s\n",
0N/A /* Extract individual fields from the cred structure */ 639N/A get the real process name out of /proc in the future 0N/A /* Set privileges */ 0N/A * For remote hosts, the uid is determined during access control 0N/A /* Set Trusted Path for local clients */ 311N/A /* Set reasonable defaults for remote clients */ 36N/A /* Use NI_NUMERICHOST to avoid DNS lookup */ 36N/A /* setup audit context */ 36N/A /* decode into msg */ 36N/A /* do the authentication */ 36N/A return ((
char *)0);
/* ((struct authdes_cred *) NULL); */ 36N/A /* Retrieve uid from SecureRPC */ 36N/A ErrorF(
"Unable to authenticate Secure RPC client");
196N/A * For multilevel desktop, limit connections to the trusted path 606N/A * i.e. global zone until a user logs in and the trusted stripe 196N/A * is in place. Unlabeled connections are rejected. 0N/A * Workstation Owner set, client must be within label 0N/A * range or have trusted path 461N/A /* Allow root from global zone */ 461N/A * Access check based on uid. Check if 461N/A * roles or other uids have been added by 36N/A /* Audit the connection */ 606N/A/* int count = rec->count; */ 679N/A * The Create case seems to be for initialization, so we don't 679N/A * want it to fail and there isn't a corresponding protocol request type. 679N/A "policy not implemented for CheckDeviceAccess(%s, %s, %s) = %s\n",
679N/A#
endif /* !NO_TSOL_DEBUG_MESSAGES */ 679N/A * Special processing for selection agent. This is how 679N/A * we know who to redirect privileged ConvertSelection requests. 679N/A * This is also used to fake the onwership of GetSelectionOwner requests. 679N/A * The callback function is only called if at least one matching selection exists. 679N/A * If it has no tsol attributes then we know it is the only match so we don't need to 679N/A * check for polyinstantiation. Just initialize it and return. 679N/A /* for poly-selections, search from the beginning to see if sl,uid match */ 679N/A * Doesn't match yet; we'll get called again 679N/A * After it gets created. 679N/A /* Assign the sl & uid */ 679N/A /* for poly-selections, search from the beginning to see if sl,uid match */ 679N/A * Doesn't match yet; we'll get called again 679N/A * After it gets created. 679N/A * Selection Agent processing. Override the owner 679N/A "policy not implemented for CheckSelectionAccess(%s, %s, %s, %s) = %s\n",
639N/A#
endif /* !NO_TSOL_DEBUG_MESSAGES */ 679N/A /* If current property is not accessible, move on to 679N/A * next one for ListProperty 679N/A /* Handle polyinstantiated property */ 679N/A /* search for a matching (sl, uid) pair */ 679N/A break;
/* match found */ 679N/A "TsolCheckPropertyAccess(%s, 0x%x, %s, %s) = %s\n",
679N/A#
endif /* !NO_TSOL_DEBUG_MESSAGES */ 0N/A * Return TRUE if host is cipso