security: drop the "declare extension security" dix call. Use the

SecurityPolicy configuration file instead.
This commit is contained in:
Eamon Walsh 2007-08-03 10:56:18 -04:00 committed by Eamon Walsh
parent e34fcd2bf4
commit d445d2f22b
10 changed files with 67 additions and 65 deletions

View File

@ -86,3 +86,8 @@ property XDCCC_GRAY_CORRECTION root ar
# To let untrusted clients use the overlay visuals that many vendors # To let untrusted clients use the overlay visuals that many vendors
# support, include this line. # support, include this line.
property SERVER_OVERLAY_VISUALS root ar property SERVER_OVERLAY_VISUALS root ar
# Only trusted extensions can be used by untrusted clients
trust extension XC-MISC
trust extension BIG-REQUESTS
trust extension XpExtension

View File

@ -66,8 +66,6 @@ BigReqExtensionInit(INITARGS)
ProcBigReqDispatch, ProcBigReqDispatch, ProcBigReqDispatch, ProcBigReqDispatch,
BigReqResetProc, StandardMinorOpcode); BigReqResetProc, StandardMinorOpcode);
#endif #endif
DeclareExtensionSecurity(XBigReqExtensionName, TRUE);
} }
/*ARGSUSED*/ /*ARGSUSED*/

View File

@ -63,8 +63,6 @@ typedef struct {
XID authId; XID authId;
} SecurityClientStateRec; } SecurityClientStateRec;
#define EXTLEVEL(extnsn) ((Bool) \
dixLookupPrivate(DEVPRIV_PTR(extnsn), &stateKey))
#define HAVESTATE(client) (((SecurityClientStateRec *) \ #define HAVESTATE(client) (((SecurityClientStateRec *) \
dixLookupPrivate(DEVPRIV_PTR(client), &stateKey))->haveState) dixLookupPrivate(DEVPRIV_PTR(client), &stateKey))->haveState)
#define TRUSTLEVEL(client) (((SecurityClientStateRec *) \ #define TRUSTLEVEL(client) (((SecurityClientStateRec *) \
@ -74,6 +72,9 @@ typedef struct {
static CallbackListPtr SecurityValidateGroupCallback = NULL; static CallbackListPtr SecurityValidateGroupCallback = NULL;
static char **SecurityTrustedExtensions = NULL;
static int nSecurityTrustedExtensions = 0;
RESTYPE SecurityAuthorizationResType; /* resource type for authorizations */ RESTYPE SecurityAuthorizationResType; /* resource type for authorizations */
static RESTYPE RTEventClient; static RESTYPE RTEventClient;
@ -1210,10 +1211,13 @@ SecurityCheckExtAccess(CallbackListPtr *pcbl, pointer unused,
pointer calldata) pointer calldata)
{ {
XaceExtAccessRec *rec = (XaceExtAccessRec*)calldata; XaceExtAccessRec *rec = (XaceExtAccessRec*)calldata;
int i, trusted = 0;
if ((TRUSTLEVEL(rec->client) != XSecurityClientTrusted) && for (i = 0; i < nSecurityTrustedExtensions; i++)
!EXTLEVEL(rec->ext)) if (!strcmp(SecurityTrustedExtensions[i], rec->ext->name))
trusted = 1;
if ((TRUSTLEVEL(rec->client) != XSecurityClientTrusted) && !trusted)
rec->status = BadAccess; rec->status = BadAccess;
} }
@ -1235,16 +1239,6 @@ SecurityCheckHostlistAccess(CallbackListPtr *pcbl, pointer unused,
} }
} }
static void
SecurityDeclareExtSecure(CallbackListPtr *pcbl, pointer unused,
pointer calldata)
{
XaceDeclareExtSecureRec *rec = (XaceDeclareExtSecureRec*)calldata;
/* security state for extensions is simply a boolean trust value */
dixSetPrivate(DEVPRIV_PTR(rec->ext), &stateKey, (pointer)rec->secure);
}
/**********************************************************************/ /**********************************************************************/
typedef struct _PropertyAccessRec { typedef struct _PropertyAccessRec {
@ -1276,7 +1270,9 @@ static char *SecurityKeywords[] = {
#define SecurityKeywordRoot 3 #define SecurityKeywordRoot 3
"root", "root",
#define SecurityKeywordAny 4 #define SecurityKeywordAny 4
"any" "any",
#define SecurityKeywordExtension 5
"trust extension",
}; };
#define NUMKEYWORDS (sizeof(SecurityKeywords) / sizeof(char *)) #define NUMKEYWORDS (sizeof(SecurityKeywords) / sizeof(char *))
@ -1500,6 +1496,36 @@ SecurityParsePropertyAccessRule(
return TRUE; return TRUE;
} /* SecurityParsePropertyAccessRule */ } /* SecurityParsePropertyAccessRule */
static Bool
SecurityParseExtensionRule(
char *p)
{
char *extName = SecurityParseString(&p);
char *copyExtName;
char **newStrings;
if (!extName)
return FALSE;
copyExtName = (char *)Xalloc(strlen(extName) + 1);
if (!copyExtName)
return TRUE;
strcpy(copyExtName, extName);
newStrings = (char **)Xrealloc(SecurityTrustedExtensions,
sizeof (char *) * (nSecurityTrustedExtensions + 1));
if (!newStrings)
{
Xfree(copyExtName);
return TRUE;
}
SecurityTrustedExtensions = newStrings;
SecurityTrustedExtensions[nSecurityTrustedExtensions++] = copyExtName;
return TRUE;
} /* SecurityParseExtensionRule */
static char **SecurityPolicyStrings = NULL; static char **SecurityPolicyStrings = NULL;
static int nSecurityPolicyStrings = 0; static int nSecurityPolicyStrings = 0;
@ -1558,6 +1584,21 @@ SecurityFreeSitePolicyStrings(void)
} }
} /* SecurityFreeSitePolicyStrings */ } /* SecurityFreeSitePolicyStrings */
static void
SecurityFreeTrustedExtensionStrings(void)
{
if (SecurityTrustedExtensions)
{
assert(nSecurityTrustedExtensions);
while (nSecurityTrustedExtensions--)
{
Xfree(SecurityTrustedExtensions[nSecurityTrustedExtensions]);
}
Xfree(SecurityTrustedExtensions);
SecurityTrustedExtensions = NULL;
nSecurityTrustedExtensions = 0;
}
} /* SecurityFreeSiteTrustedExtensions */
static void static void
SecurityLoadPropertyAccessList(void) SecurityLoadPropertyAccessList(void)
@ -1616,6 +1657,10 @@ SecurityLoadPropertyAccessList(void)
validLine = SecurityParseSitePolicy(p); validLine = SecurityParseSitePolicy(p);
break; break;
case SecurityKeywordExtension:
validLine = SecurityParseExtensionRule(p);
break;
default: default:
validLine = (*p == '\0'); /* blank lines OK, others not */ validLine = (*p == '\0'); /* blank lines OK, others not */
break; break;
@ -1791,6 +1836,7 @@ SecurityResetProc(
ExtensionEntry *extEntry) ExtensionEntry *extEntry)
{ {
SecurityFreePropertyAccessList(); SecurityFreePropertyAccessList();
SecurityFreeTrustedExtensionStrings();
SecurityFreeSitePolicyStrings(); SecurityFreeSitePolicyStrings();
} /* SecurityResetProc */ } /* SecurityResetProc */
@ -1811,32 +1857,6 @@ XSecurityOptions(argc, argv, i)
} /* XSecurityOptions */ } /* XSecurityOptions */
/* SecurityExtensionSetup
*
* Arguments: none.
*
* Returns: nothing.
*
* Side Effects:
* Sets up the Security extension if possible.
* This function contains things that need to be done
* before any other extension init functions get called.
*/
void
SecurityExtensionSetup(INITARGS)
{
/* FIXME: this is here so it is registered before other extensions
* init themselves. This also required commit 5e946dd853a4ebc... to
* call the setup functions on each server reset.
*
* The extension security bit should be delivered in some other way,
* either in a symbol or in the module data.
*/
XaceRegisterCallback(XACE_DECLARE_EXT_SECURE, SecurityDeclareExtSecure, 0);
} /* SecurityExtensionSetup */
/* SecurityExtensionInit /* SecurityExtensionInit
* *
* Arguments: none. * Arguments: none.

View File

@ -80,8 +80,6 @@ XCMiscExtensionInit(INITARGS)
ProcXCMiscDispatch, SProcXCMiscDispatch, ProcXCMiscDispatch, SProcXCMiscDispatch,
XCMiscResetProc, StandardMinorOpcode); XCMiscResetProc, StandardMinorOpcode);
#endif #endif
DeclareExtensionSecurity(XCMiscExtensionName, TRUE);
} }
/*ARGSUSED*/ /*ARGSUSED*/

View File

@ -335,7 +335,6 @@ XpExtensionInit(INITARGS)
screenInfo.screens[i]->CloseScreen = XpCloseScreen; screenInfo.screens[i]->CloseScreen = XpCloseScreen;
} }
} }
DeclareExtensionSecurity(XP_PRINTNAME, TRUE);
} }
static void static void

View File

@ -250,14 +250,6 @@ GetExtensionEntry(int major)
return extensions[major]; return extensions[major];
} }
_X_EXPORT void
DeclareExtensionSecurity(char *extname, Bool secure)
{
int i = FindExtension(extname, strlen(extname));
if (i >= 0)
XaceHook(XACE_DECLARE_EXT_SECURE, extensions[i], secure);
}
_X_EXPORT unsigned short _X_EXPORT unsigned short
StandardMinorOpcode(ClientPtr client) StandardMinorOpcode(ClientPtr client)
{ {

View File

@ -135,7 +135,6 @@ extern void XSELinuxExtensionInit(INITARGS);
#endif #endif
#if 1 #if 1
extern void SecurityExtensionSetup(INITARGS);
extern void SecurityExtensionInit(INITARGS); extern void SecurityExtensionInit(INITARGS);
#endif #endif

View File

@ -200,7 +200,6 @@ _X_HIDDEN void *dixLookupTab[] = {
SYMFUNC(AddExtension) SYMFUNC(AddExtension)
SYMFUNC(AddExtensionAlias) SYMFUNC(AddExtensionAlias)
SYMFUNC(CheckExtension) SYMFUNC(CheckExtension)
SYMFUNC(DeclareExtensionSecurity)
SYMFUNC(MinorOpcodeOfRequest) SYMFUNC(MinorOpcodeOfRequest)
SYMFUNC(StandardMinorOpcode) SYMFUNC(StandardMinorOpcode)
#ifdef XEVIE #ifdef XEVIE

View File

@ -107,9 +107,5 @@ extern Bool AddExtensionAlias(
extern ExtensionEntry *CheckExtension(const char *extname); extern ExtensionEntry *CheckExtension(const char *extname);
extern ExtensionEntry *GetExtensionEntry(int major); extern ExtensionEntry *GetExtensionEntry(int major);
extern void DeclareExtensionSecurity(
char * /*extname*/,
Bool /*secure*/);
#endif /* EXTENSIONSTRUCT_H */ #endif /* EXTENSIONSTRUCT_H */

View File

@ -321,7 +321,6 @@ extern void XagExtensionInit(INITARGS);
extern void XaceExtensionInit(INITARGS); extern void XaceExtensionInit(INITARGS);
#endif #endif
#ifdef XCSECURITY #ifdef XCSECURITY
extern void SecurityExtensionSetup(INITARGS);
extern void SecurityExtensionInit(INITARGS); extern void SecurityExtensionInit(INITARGS);
#endif #endif
#ifdef XSELINUX #ifdef XSELINUX
@ -538,9 +537,6 @@ InitExtensions(argc, argv)
int argc; int argc;
char *argv[]; char *argv[];
{ {
#ifdef XCSECURITY
SecurityExtensionSetup();
#endif
#ifdef XSELINUX #ifdef XSELINUX
XSELinuxExtensionSetup(); XSELinuxExtensionSetup();
#endif #endif
@ -719,7 +715,7 @@ static ExtensionModule staticExtensions[] = {
{ XaceExtensionInit, XACE_EXTENSION_NAME, NULL, NULL, NULL }, { XaceExtensionInit, XACE_EXTENSION_NAME, NULL, NULL, NULL },
#endif #endif
#ifdef XCSECURITY #ifdef XCSECURITY
{ SecurityExtensionInit, SECURITY_EXTENSION_NAME, &noSecurityExtension, SecurityExtensionSetup, NULL }, { SecurityExtensionInit, SECURITY_EXTENSION_NAME, &noSecurityExtension, NULL, NULL },
#endif #endif
#ifdef XSELINUX #ifdef XSELINUX
{ XSELinuxExtensionInit, XSELINUX_EXTENSION_NAME, NULL, XSELinuxExtensionSetup, NULL }, { XSELinuxExtensionInit, XSELINUX_EXTENSION_NAME, NULL, XSELinuxExtensionSetup, NULL },