only load user addons when not in safe mode

fixes bug #842


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18817 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2006-09-12 08:45:29 +00:00
parent af7808fe71
commit 225a60f167
2 changed files with 29 additions and 2 deletions
+28 -2
View File
@@ -21,6 +21,7 @@
#include <Autolock.h>
#include <Directory.h>
#include <FindDirectory.h>
#include <driver_settings.h>
#include <image.h>
#include <NodeMonitor.h>
#include <Path.h>
@@ -30,6 +31,14 @@
#include <new>
#include <string.h>
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
extern "C" status_t _kern_get_safemode_option(const char *parameter,
char *buffer, size_t *_bufferSize);
#else
extern "C" status_t _kget_safemode_option_(const char *parameter,
char *buffer, size_t *_bufferSize);
#endif
#if !defined(HAIKU_TARGET_PLATFORM_HAIKU) && !defined(HAIKU_TARGET_PLATFORM_LIBBE_TEST)
// building under R5 or Dano/Zeta
@@ -124,8 +133,25 @@ QuarantineTranslatorImage::Remove()
BTranslatorRoster::Private::Private()
: BHandler("translator roster"), BLocker("translator list"),
fNextID(1),
fLazyScanning(true)
fLazyScanning(true),
fSafeMode(false)
{
char parameter[32];
size_t parameterLength = sizeof(parameter);
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
if (_kern_get_safemode_option(B_SAFEMODE_SAFE_MODE, parameter, &parameterLength) == B_OK)
#else
if (_kget_safemode_option_(B_SAFEMODE_SAFE_MODE, parameter, &parameterLength) == B_OK)
#endif
{
if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on")
|| !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes")
|| !strcasecmp(parameter, "enable") || !strcmp(parameter, "1"))
fSafeMode = true;
}
// we're sneaking us into the BApplication
if (be_app != NULL && be_app->Lock()) {
be_app->AddHandler(this);
@@ -288,7 +314,7 @@ BTranslatorRoster::Private::AddDefaultPaths()
B_BEOS_ADDONS_DIRECTORY,
};
for (uint32 i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
for (uint32 i = fSafeMode ? 1 : 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
BPath path;
status_t status = find_directory(paths[i], &path, true);
if (status == B_OK && path.Append("Translators") == B_OK) {
@@ -101,6 +101,7 @@ class BTranslatorRoster::Private : public BHandler, public BLocker {
EntryRefSet fRescanEntries;
int32 fNextID;
bool fLazyScanning;
bool fSafeMode;
};
#endif // TRANSLATOR_ROSTER_PRIVATE_H