Kaydet (Commit) e1e308bc authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Remove support for UNO_AC* bootstrap variables

...they had effectively never been used.

Change-Id: I514f2b844661e144cef758eb3ce7c4607ffad635
üst fb8f3fac
...@@ -59,7 +59,6 @@ ...@@ -59,7 +59,6 @@
#define SMGR_SINGLETON "/singletons/com.sun.star.lang.theServiceManager" #define SMGR_SINGLETON "/singletons/com.sun.star.lang.theServiceManager"
#define TDMGR_SINGLETON "/singletons/com.sun.star.reflection.theTypeDescriptionManager" #define TDMGR_SINGLETON "/singletons/com.sun.star.reflection.theTypeDescriptionManager"
#define AC_SINGLETON "/singletons/com.sun.star.security.theAccessController" #define AC_SINGLETON "/singletons/com.sun.star.security.theAccessController"
#define AC_POLICY "/singletons/com.sun.star.security.thePolicy"
#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
...@@ -694,7 +693,7 @@ void ComponentContext::disposing() ...@@ -694,7 +693,7 @@ void ComponentContext::disposing()
::fprintf( stderr, "> disposing context %p\n", this ); ::fprintf( stderr, "> disposing context %p\n", this );
#endif #endif
Reference< lang::XComponent > xTDMgr, xAC, xPolicy; // to be disposed separately Reference< lang::XComponent > xTDMgr, xAC; // to be disposed separately
// dispose all context objects // dispose all context objects
t_map::const_iterator iPos( m_map.begin() ); t_map::const_iterator iPos( m_map.begin() );
...@@ -731,10 +730,6 @@ void ComponentContext::disposing() ...@@ -731,10 +730,6 @@ void ComponentContext::disposing()
{ {
xAC = xComp; xAC = xComp;
} }
else if ( iPos->first == AC_POLICY )
{
xPolicy = xComp;
}
else // dispose immediately else // dispose immediately
{ {
xComp->dispose(); xComp->dispose();
...@@ -748,8 +743,6 @@ void ComponentContext::disposing() ...@@ -748,8 +743,6 @@ void ComponentContext::disposing()
m_xSMgr.clear(); m_xSMgr.clear();
// dispose ac // dispose ac
try_dispose( xAC ); try_dispose( xAC );
// dispose policy
try_dispose( xPolicy );
// dispose tdmgr; revokes callback from cppu runtime // dispose tdmgr; revokes callback from cppu runtime
try_dispose( xTDMgr ); try_dispose( xTDMgr );
......
...@@ -115,7 +115,7 @@ cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri) ...@@ -115,7 +115,7 @@ cppu::defaultBootstrap_InitialComponentContext(rtl::OUString const & iniUri)
"/singletons/" + i->first, "/singletons/" + i->first,
css::uno::makeAny(i->second[0]->info->name), true)); css::uno::makeAny(i->second[0]->info->name), true));
} }
cppu::add_access_control_entries(&context_values, bs); cppu::add_access_control_entries(&context_values);
assert(!context_values.empty()); assert(!context_values.empty());
css::uno::Reference< css::uno::XComponentContext > context( css::uno::Reference< css::uno::XComponentContext > context(
createComponentContext( createComponentContext(
......
...@@ -40,151 +40,22 @@ using namespace ::com::sun::star::uno; ...@@ -40,151 +40,22 @@ using namespace ::com::sun::star::uno;
namespace cppu namespace cppu
{ {
/** bootstrap variables: void add_access_control_entries( ::std::vector< ContextEntry_Init > * values )
UNO_AC=<mode> [mandatory]
-- mode := { on, off, dynamic-only, single-user, single-default-user }
UNO_AC_SERVICE=<service_name> [optional]
-- override ac singleton service name
UNO_AC_SINGLEUSER=<user-id|nothing> [optional]
-- run with this user id or with default user policy (<nothing>)
set UNO_AC=single-[default-]user
UNO_AC_USERCACHE_SIZE=<cache_size>
-- number of user permission sets to be cached
UNO_AC_POLICYSERVICE=<service_name> [optional]
-- override policy singleton service name
UNO_AC_POLICYFILE=<file_url> [optional]
-- read policy out of simple text file
*/
void add_access_control_entries(
::std::vector< ContextEntry_Init > * values,
Bootstrap const & bootstrap )
SAL_THROW( (Exception) ) SAL_THROW( (Exception) )
{ {
ContextEntry_Init entry; ContextEntry_Init entry;
::std::vector< ContextEntry_Init > & context_values = *values; ::std::vector< ContextEntry_Init > & context_values = *values;
OUString ac_policy;
if (bootstrap.getFrom( OUSTR("UNO_AC_POLICYSERVICE"), ac_policy ))
{
// overridden service name
// - policy singleton
entry.bLateInitService = true;
entry.name = OUSTR("/singletons/com.sun.star.security.thePolicy");
entry.value <<= ac_policy;
context_values.push_back( entry );
}
else if (bootstrap.getFrom( OUSTR("UNO_AC_POLICYFILE"), ac_policy ))
{
// check for file policy
// - file policy prop: file-name
if (0 != ac_policy.compareToAscii(
RTL_CONSTASCII_STRINGPARAM("file:///") ))
{
// no file url
OUString baseDir;
if ( ::osl_getProcessWorkingDir( &baseDir.pData )
!= osl_Process_E_None )
{
OSL_ASSERT( false );
}
OUString fileURL;
if ( ::osl_getAbsoluteFileURL(
baseDir.pData, ac_policy.pData, &fileURL.pData )
!= osl_File_E_None )
{
OSL_ASSERT( false );
}
ac_policy = fileURL;
}
entry.bLateInitService = false;
entry.name =
OUSTR("/implementations/com.sun.star.security.comp.stoc.FilePolicy/"
"file-name");
entry.value <<= ac_policy;
context_values.push_back( entry );
// - policy singleton
entry.bLateInitService = true;
entry.name = OUSTR("/singletons/com.sun.star.security.thePolicy");
entry.value <<= OUSTR("com.sun.star.security.comp.stoc.FilePolicy");
context_values.push_back( entry );
} // else policy singleton comes from storage
OUString ac_mode;
if (! bootstrap.getFrom( OUSTR("UNO_AC"), ac_mode ))
{
ac_mode = OUSTR("off"); // default
}
OUString ac_user;
if (bootstrap.getFrom( OUSTR("UNO_AC_SINGLEUSER"), ac_user ))
{
// ac in single-user mode
if (!ac_user.isEmpty())
{
// - ac prop: single-user-id
entry.bLateInitService = false;
entry.name =
OUSTR("/services/com.sun.star.security.AccessController/"
"single-user-id");
entry.value <<= ac_user;
context_values.push_back( entry );
if ( ac_mode != "single-user" )
{
throw SecurityException(
OUSTR("set UNO_AC=single-user "
"if you set UNO_AC_SINGLEUSER=<user-id>!"),
Reference< XInterface >() );
}
}
else
{
if ( ac_mode != "single-default-user" )
{
throw SecurityException(
OUSTR("set UNO_AC=single-default-user "
"if you set UNO_AC_SINGLEUSER=<nothing>!"),
Reference< XInterface >() );
}
}
}
OUString ac_service;
if (! bootstrap.getFrom( OUSTR("UNO_AC_SERVICE"), ac_service ))
{
// override service name
ac_service = OUSTR("com.sun.star.security.AccessController"); // default
// ac = OUSTR("com.sun.star.security.comp.stoc.AccessController");
}
// - ac prop: user-cache-size
OUString ac_cache;
if (bootstrap.getFrom( OUSTR("UNO_AC_USERCACHE_SIZE"), ac_cache ))
{
// ac cache size
sal_Int32 n = ac_cache.toInt32();
if (0 < n)
{
entry.bLateInitService = false;
entry.name =
OUSTR("/services/com.sun.star.security.AccessController/"
"user-cache-size");
entry.value <<= n;
context_values.push_back( entry );
}
}
// - ac prop: mode // - ac prop: mode
// { "off", "on", "dynamic-only", "single-user", "single-default-user" } // { "off", "on", "dynamic-only", "single-user", "single-default-user" }
entry.bLateInitService = false; entry.bLateInitService = false;
entry.name = OUSTR("/services/com.sun.star.security.AccessController/mode"); entry.name = OUSTR("/services/com.sun.star.security.AccessController/mode");
entry.value <<= ac_mode; entry.value <<= OUSTR("off");
context_values.push_back( entry ); context_values.push_back( entry );
// - ac singleton // - ac singleton
entry.bLateInitService = true; entry.bLateInitService = true;
entry.name = OUSTR("/singletons/com.sun.star.security.theAccessController"); entry.name = OUSTR("/singletons/com.sun.star.security.theAccessController");
entry.value <<= ac_service; entry.value <<= OUSTR("com.sun.star.security.AccessController");
context_values.push_back( entry ); context_values.push_back( entry );
} }
......
...@@ -28,13 +28,10 @@ ...@@ -28,13 +28,10 @@
#include "sal/types.h" #include "sal/types.h"
namespace cppu { struct ContextEntry_Init; } namespace cppu { struct ContextEntry_Init; }
namespace rtl { class Bootstrap; }
namespace cppu { namespace cppu {
void add_access_control_entries( void add_access_control_entries(std::vector< cppu::ContextEntry_Init > * values)
std::vector< cppu::ContextEntry_Init > * values,
rtl::Bootstrap const & bootstrap)
SAL_THROW((com::sun::star::uno::Exception)); SAL_THROW((com::sun::star::uno::Exception));
} }
......
...@@ -472,6 +472,10 @@ AccessController::AccessController( Reference< XComponentContext > const & xComp ...@@ -472,6 +472,10 @@ AccessController::AccessController( Reference< XComponentContext > const & xComp
{ {
g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt );
// The .../mode value had originally been set in
// cppu::add_access_control_entries (cppuhelper/source/servicefactory.cxx)
// to something other than "off" depending on various UNO_AC* bootstrap
// variables that are no longer supported, so this is mostly dead code now:
OUString mode; OUString mode;
if (m_xComponentContext->getValueByName( OUSTR("/services/" SERVICE_NAME "/mode") ) >>= mode) if (m_xComponentContext->getValueByName( OUSTR("/services/" SERVICE_NAME "/mode") ) >>= mode)
{ {
......
...@@ -438,7 +438,10 @@ PolicyReader::~PolicyReader() ...@@ -438,7 +438,10 @@ PolicyReader::~PolicyReader()
void FilePolicy::refresh() void FilePolicy::refresh()
throw (RuntimeException) throw (RuntimeException)
{ {
// read out file // read out file (the .../file-name value had originally been set in
// cppu::add_access_control_entries (cppuhelper/source/servicefactory.cxx)
// depending on various UNO_AC* bootstrap variables that are no longer
// supported, so this is effectively dead code):
OUString fileName; OUString fileName;
m_xComponentContext->getValueByName( m_xComponentContext->getValueByName(
OUSTR("/implementations/" IMPL_NAME "/file-name") ) >>= fileName; OUSTR("/implementations/" IMPL_NAME "/file-name") ) >>= fileName;
......
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
PRJ=..$/..
PRJNAME=stoc
TARGET=test_security
TARGETTYPE=CUI
LIBTARGET=NO
ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
# --- Application 1 ------------------------------------------------
APP1TARGET= $(TARGET)
APP1OBJS= $(OBJ)$/test_security.obj
APP1STDLIBS= \
$(CPPULIB) \
$(CPPUHELPERLIB) \
$(SALHELPERLIB) \
$(SALLIB)
.IF "$(OS)"=="WNT"
APP1STDLIBS+=
# $(LIBCIMT) $(LIBCMT)
.ENDIF
# --- Target ------------------------------------------------
.INCLUDE : target.mk
This diff is collapsed.
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
UNO_TYPES=stoctest.rdb
UNO_SERVICES=stoctest.rdb
UNO_WRITERDB=stoctest.rdb
UNO_AC=on
UNO_AC_POLICYFILE=../../test/security/test_security.policy
UNO_AC_USERCACHE_SIZE=2
/** dbo
permissions
*/
grant user "dbo"{
permission com.sun.star.io.FilePermission "file:///home/dbo/-", ",,read , write ";
permission com.sun.star.io.FilePermission "-", "read ,write";
permission com.sun.star.connection.SocketPermission "dbo-1:1024-", "listen";
permission com.sun.star.security.RuntimePermission "DBO";
permission com.sun.star.connection.SocketPermission "dbo-11081:-1023", "resolve";
permission com.sun.star.connection.SocketPermission "dbo-11081:18", "listen";
permission com.sun.star.connection.SocketPermission "dbo-11081:20-24", "listen";
permission com.sun.star.connection.SocketPermission "dbo-11081", "connect";
permission com.sun.star.io.FilePermission "file:///usr/local/dbo/*" , "read ";};
grant user "jbu" {
permission com.sun.star.security.RuntimePermission "JBU";
permission com.sun.star.io.FilePermission "file:///home/jbu/-" ,"read,write,";
/*jbu resolve*/permission com.sun.star.connection.SocketPermission "jbu-11096","resolve";
permission com.sun.star.io.FilePermission "*",",read,write";}; grant user "root"{permission com.sun.star.security.AllPermission;};
// granted to anyone
grant
{
// read out this file
permission com.sun.star.io.FilePermission "../../test/security/test_security.policy",
"read";
permission com.sun.star.security.RuntimePermission "DEF";
permission com.sun.star.io.FilePermission "file:///usr/bin/*", "read";
permission com.sun.star.io.FilePermission "file:///usr/bin/*", "read";
permission com.sun.star.io.FilePermission "file:///tmp/-", "read, write";
permission com.sun.star.io.FilePermission "file:///etc/profile", "read,,";
permission com.sun.star.connection.SocketPermission "127.0.0.1:-1023", "resolve, connect, listen";
permission com.sun.star.connection.SocketPermission "localhost:1024-", "accept, connect, listen, resolve,";
permission com.sun.star.connection.SocketPermission "*.sun.com:1024-", "resolve";
} ;
# eof
\ No newline at end of file
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
UNO_TYPES=stoctest.rdb
UNO_SERVICES=stoctest.rdb
UNO_WRITERDB=stoctest.rdb
UNO_AC=single-user
UNO_AC_SINGLEUSER=dbo
UNO_AC_POLICYFILE=../../test/security/test_security.policy
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment