/** * Peforms intialization of the MANDATORY components of the Video Engine */ MediaConduitErrorCode WebrtcVideoConduit::Init() { CSFLogDebug(logTag, "%s ", __FUNCTION__); #ifdef MOZ_WIDGET_ANDROID jobject context = jsjni_GetGlobalContextRef(); // get the JVM JavaVM *jvm = jsjni_GetVM(); JNIEnv* env; if (jvm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) { CSFLogError(logTag, "%s: could not get Java environment", __FUNCTION__); return kMediaConduitSessionNotInited; } jvm->AttachCurrentThread(&env, nullptr); if (webrtc::VideoEngine::SetAndroidObjects(jvm, (void*)context) != 0) { CSFLogError(logTag, "%s: could not set Android objects", __FUNCTION__); return kMediaConduitSessionNotInited; } env->DeleteGlobalRef(context); #endif if( !(mVideoEngine = webrtc::VideoEngine::Create()) ) { CSFLogError(logTag, "%s Unable to create video engine ", __FUNCTION__); return kMediaConduitSessionNotInited; } PRLogModuleInfo *logs = GetWebRTCLogInfo(); if (!gWebrtcTraceLoggingOn && logs && logs->level > 0) { // no need to a critical section or lock here gWebrtcTraceLoggingOn = 1; const char *file = PR_GetEnv("WEBRTC_TRACE_FILE"); if (!file) { file = "WebRTC.log"; } CSFLogDebug(logTag, "%s Logging webrtc to %s level %d", __FUNCTION__, file, logs->level); mVideoEngine->SetTraceFilter(logs->level); mVideoEngine->SetTraceFile(file); } if( !(mPtrViEBase = ViEBase::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video base interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrViECapture = ViECapture::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video capture interface", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrViECodec = ViECodec::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video codec interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrViENetwork = ViENetwork::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video network interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrViERender = ViERender::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video render interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrRTP = webrtc::ViERTP_RTCP::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video RTCP interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } CSFLogDebug(logTag, "%s Engine Created: Init'ng the interfaces ",__FUNCTION__); if(mPtrViEBase->Init() == -1) { CSFLogError(logTag, " %s Video Engine Init Failed %d ",__FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitSessionNotInited; } if(mPtrViEBase->CreateChannel(mChannel) == -1) { CSFLogError(logTag, " %s Channel creation Failed %d ",__FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitChannelError; } if(mPtrViENetwork->RegisterSendTransport(mChannel, *this) == -1) { CSFLogError(logTag, "%s ViENetwork Failed %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitTransportRegistrationFail; } mPtrExtCapture = 0; if(mPtrViECapture->AllocateExternalCaptureDevice(mCapId, mPtrExtCapture) == -1) { CSFLogError(logTag, "%s Unable to Allocate capture module: %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitCaptureError; } if(mPtrViECapture->ConnectCaptureDevice(mCapId,mChannel) == -1) { CSFLogError(logTag, "%s Unable to Connect capture module: %d ", __FUNCTION__,mPtrViEBase->LastError()); return kMediaConduitCaptureError; } if(mPtrViERender->AddRenderer(mChannel, webrtc::kVideoI420, (webrtc::ExternalRenderer*) this) == -1) { CSFLogError(logTag, "%s Failed to added external renderer ", __FUNCTION__); return kMediaConduitInvalidRenderer; } // Set up some parameters, per juberti. Set MTU. if(mPtrViENetwork->SetMTU(mChannel, 1200) != 0) { CSFLogError(logTag, "%s MTU Failed %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitMTUError; } // Turn on RTCP and loss feedback reporting. if(mPtrRTP->SetRTCPStatus(mChannel, webrtc::kRtcpCompound_RFC4585) != 0) { CSFLogError(logTag, "%s RTCPStatus Failed %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitRTCPStatusError; } // Enable pli as key frame request method. if(mPtrRTP->SetKeyFrameRequestMethod(mChannel, webrtc::kViEKeyFrameRequestPliRtcp) != 0) { CSFLogError(logTag, "%s KeyFrameRequest Failed %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitKeyFrameRequestError; } // Enable lossless transport // XXX Note: We may want to disable this or limit it if (mPtrRTP->SetNACKStatus(mChannel, true) != 0) { CSFLogError(logTag, "%s NACKStatus Failed %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitNACKStatusError; } CSFLogError(logTag, "%s Initialization Done", __FUNCTION__); return kMediaConduitNoError; }
void _PR_InitLog(void) { char *ev; _pr_logLock = PR_NewLock(); ev = PR_GetEnv("NSPR_LOG_MODULES"); if (ev && ev[0]) { char module[64]; /* Security-Critical: If you change this * size, you must also change the sscanf * format string to be size-1. */ PRBool isSync = PR_FALSE; PRIntn evlen = strlen(ev), pos = 0; PRInt32 bufSize = DEFAULT_BUF_SIZE; while (pos < evlen) { PRIntn level = 1, count = 0, delta = 0; count = sscanf(&ev[pos], "%63[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-]%n:%d%n", module, &delta, &level, &delta); pos += delta; if (count == 0) break; /* ** If count == 2, then we got module and level. If count ** == 1, then level defaults to 1 (module enabled). */ if (strcasecmp(module, "sync") == 0) { isSync = PR_TRUE; } else if (strcasecmp(module, "bufsize") == 0) { if (level >= LINE_BUF_SIZE) { bufSize = level; } } else if (strcasecmp(module, "timestamp") == 0) { outputTimeStamp = PR_TRUE; } else if (strcasecmp(module, "append") == 0) { appendToLog = PR_TRUE; } else { PRLogModuleInfo *lm = logModules; PRBool skip_modcheck = (0 == strcasecmp (module, "all")) ? PR_TRUE : PR_FALSE; while (lm != NULL) { if (skip_modcheck) lm -> level = (PRLogModuleLevel)level; else if (strcasecmp(module, lm->name) == 0) { lm->level = (PRLogModuleLevel)level; break; } lm = lm->next; } } /*found:*/ count = sscanf(&ev[pos], " , %n", &delta); pos += delta; if (count == EOF) break; } PR_SetLogBuffering(isSync ? 0 : bufSize); #ifdef XP_UNIX if ((getuid() != geteuid()) || (getgid() != getegid())) { return; } #endif /* XP_UNIX */ ev = PR_GetEnv("NSPR_LOG_FILE"); if (ev && ev[0]) { if (!PR_SetLogFile(ev)) { #ifdef XP_PC char* str = PR_smprintf("Unable to create nspr log file '%s'\n", ev); if (str) { OutputDebugStringA(str); PR_smprintf_free(str); } #else fprintf(stderr, "Unable to create nspr log file '%s'\n", ev); #endif } } else { #ifdef _PR_USE_STDIO_FOR_LOGGING logFile = stderr; #else logFile = _pr_stderr; #endif } } }
bool ShouldA11yBeEnabled() { static bool sChecked = false, sShouldEnable = false; if (sChecked) return sShouldEnable; sChecked = true; EPlatformDisabledState disabledState = PlatformDisabledState(); if (disabledState == ePlatformIsDisabled) return sShouldEnable = false; // check if accessibility enabled/disabled by environment variable const char* envValue = PR_GetEnv(sAccEnv); if (envValue) return sShouldEnable = !!atoi(envValue); #ifdef MOZ_ENABLE_DBUS PreInit(); bool dbusSuccess = false; DBusMessage *reply = nullptr; if (!sPendingCall) goto dbus_done; dbus_pending_call_block(sPendingCall); reply = dbus_pending_call_steal_reply(sPendingCall); dbus_pending_call_unref(sPendingCall); sPendingCall = nullptr; if (!reply || dbus_message_get_type(reply) != DBUS_MESSAGE_TYPE_METHOD_RETURN || strcmp(dbus_message_get_signature (reply), DBUS_TYPE_VARIANT_AS_STRING)) goto dbus_done; DBusMessageIter iter, iter_variant, iter_struct; dbus_bool_t dResult; dbus_message_iter_init(reply, &iter); dbus_message_iter_recurse (&iter, &iter_variant); switch (dbus_message_iter_get_arg_type(&iter_variant)) { case DBUS_TYPE_STRUCT: // at-spi2-core 2.2.0-2.2.1 had a bug where it returned a struct dbus_message_iter_recurse(&iter_variant, &iter_struct); if (dbus_message_iter_get_arg_type(&iter_struct) == DBUS_TYPE_BOOLEAN) { dbus_message_iter_get_basic(&iter_struct, &dResult); sShouldEnable = dResult; dbusSuccess = true; } break; case DBUS_TYPE_BOOLEAN: dbus_message_iter_get_basic(&iter_variant, &dResult); sShouldEnable = dResult; dbusSuccess = true; break; default: break; } dbus_done: if (reply) dbus_message_unref(reply); if (dbusSuccess) return sShouldEnable; #endif //check gconf-2 setting static const char sGconfAccessibilityKey[] = "/desktop/gnome/interface/accessibility"; nsresult rv = NS_OK; nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID, &rv); if (NS_SUCCEEDED(rv) && gconf) gconf->GetBool(NS_LITERAL_CSTRING(sGconfAccessibilityKey), &sShouldEnable); return sShouldEnable; }
/** * Peforms intialization of the MANDATORY components of the Video Engine */ MediaConduitErrorCode WebrtcVideoConduit::Init(WebrtcVideoConduit *other) { CSFLogDebug(logTag, "%s this=%p other=%p", __FUNCTION__, this, other); if (other) { MOZ_ASSERT(!other->mOtherDirection); other->mOtherDirection = this; mOtherDirection = other; // only one can call ::Create()/GetVideoEngine() MOZ_ASSERT(other->mVideoEngine); mVideoEngine = other->mVideoEngine; } else { #ifdef MOZ_WIDGET_ANDROID jobject context = jsjni_GetGlobalContextRef(); // get the JVM JavaVM *jvm = jsjni_GetVM(); if (webrtc::VideoEngine::SetAndroidObjects(jvm, (void*)context) != 0) { CSFLogError(logTag, "%s: could not set Android objects", __FUNCTION__); return kMediaConduitSessionNotInited; } #endif // Per WebRTC APIs below function calls return nullptr on failure if( !(mVideoEngine = webrtc::VideoEngine::Create()) ) { CSFLogError(logTag, "%s Unable to create video engine ", __FUNCTION__); return kMediaConduitSessionNotInited; } PRLogModuleInfo *logs = GetWebRTCLogInfo(); if (!gWebrtcTraceLoggingOn && logs && logs->level > 0) { // no need to a critical section or lock here gWebrtcTraceLoggingOn = 1; const char *file = PR_GetEnv("WEBRTC_TRACE_FILE"); if (!file) { file = "WebRTC.log"; } CSFLogDebug(logTag, "%s Logging webrtc to %s level %d", __FUNCTION__, file, logs->level); mVideoEngine->SetTraceFilter(logs->level); mVideoEngine->SetTraceFile(file); } } if( !(mPtrViEBase = ViEBase::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video base interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrViECapture = ViECapture::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video capture interface", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrViECodec = ViECodec::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video codec interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrViENetwork = ViENetwork::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video network interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrViERender = ViERender::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video render interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrRTP = webrtc::ViERTP_RTCP::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video RTCP interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } if ( !(mPtrExtCodec = webrtc::ViEExternalCodec::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get external codec interface %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitSessionNotInited; } if (other) { mChannel = other->mChannel; mPtrExtCapture = other->mPtrExtCapture; mCapId = other->mCapId; } else { CSFLogDebug(logTag, "%s Engine Created: Init'ng the interfaces ",__FUNCTION__); if(mPtrViEBase->Init() == -1) { CSFLogError(logTag, " %s Video Engine Init Failed %d ",__FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitSessionNotInited; } if(mPtrViEBase->CreateChannel(mChannel) == -1) { CSFLogError(logTag, " %s Channel creation Failed %d ",__FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitChannelError; } if(mPtrViENetwork->RegisterSendTransport(mChannel, *this) == -1) { CSFLogError(logTag, "%s ViENetwork Failed %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitTransportRegistrationFail; } if(mPtrViECapture->AllocateExternalCaptureDevice(mCapId, mPtrExtCapture) == -1) { CSFLogError(logTag, "%s Unable to Allocate capture module: %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitCaptureError; } if(mPtrViECapture->ConnectCaptureDevice(mCapId,mChannel) == -1) { CSFLogError(logTag, "%s Unable to Connect capture module: %d ", __FUNCTION__,mPtrViEBase->LastError()); return kMediaConduitCaptureError; } if(mPtrViERender->AddRenderer(mChannel, webrtc::kVideoI420, (webrtc::ExternalRenderer*) this) == -1) { CSFLogError(logTag, "%s Failed to added external renderer ", __FUNCTION__); return kMediaConduitInvalidRenderer; } // Set up some parameters, per juberti. Set MTU. if(mPtrViENetwork->SetMTU(mChannel, 1200) != 0) { CSFLogError(logTag, "%s MTU Failed %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitMTUError; } // Turn on RTCP and loss feedback reporting. if(mPtrRTP->SetRTCPStatus(mChannel, webrtc::kRtcpCompound_RFC4585) != 0) { CSFLogError(logTag, "%s RTCPStatus Failed %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitRTCPStatusError; } } CSFLogError(logTag, "%s Initialization Done", __FUNCTION__); return kMediaConduitNoError; }
/* * WebRTCAudioConduit Implementation */ MediaConduitErrorCode WebrtcAudioConduit::Init(WebrtcAudioConduit *other) { CSFLogDebug(logTag, "%s this=%p other=%p", __FUNCTION__, this, other); if (other) { MOZ_ASSERT(!other->mOtherDirection); other->mOtherDirection = this; mOtherDirection = other; // only one can call ::Create()/GetVoiceEngine() MOZ_ASSERT(other->mVoiceEngine); mVoiceEngine = other->mVoiceEngine; } else { #ifdef MOZ_WIDGET_ANDROID jobject context = jsjni_GetGlobalContextRef(); // get the JVM JavaVM *jvm = jsjni_GetVM(); JNIEnv* env; if (jvm->GetEnv((void**)&env, JNI_VERSION_1_4) != JNI_OK) { CSFLogError(logTag, "%s: could not get Java environment", __FUNCTION__); return kMediaConduitSessionNotInited; } jvm->AttachCurrentThread(&env, NULL); if (webrtc::VoiceEngine::SetAndroidObjects(jvm, (void*)context) != 0) { CSFLogError(logTag, "%s Unable to set Android objects", __FUNCTION__); return kMediaConduitSessionNotInited; } env->DeleteGlobalRef(context); #endif //Per WebRTC APIs below function calls return NULL on failure if(!(mVoiceEngine = webrtc::VoiceEngine::Create())) { CSFLogError(logTag, "%s Unable to create voice engine", __FUNCTION__); return kMediaConduitSessionNotInited; } PRLogModuleInfo *logs = GetWebRTCLogInfo(); if (!gWebrtcTraceLoggingOn && logs && logs->level > 0) { // no need to a critical section or lock here gWebrtcTraceLoggingOn = 1; const char *file = PR_GetEnv("WEBRTC_TRACE_FILE"); if (!file) { file = "WebRTC.log"; } CSFLogDebug(logTag, "%s Logging webrtc to %s level %d", __FUNCTION__, file, logs->level); mVoiceEngine->SetTraceFilter(logs->level); mVoiceEngine->SetTraceFile(file); } } if(!(mPtrVoEBase = VoEBase::GetInterface(mVoiceEngine))) { CSFLogError(logTag, "%s Unable to initialize VoEBase", __FUNCTION__); return kMediaConduitSessionNotInited; } if(!(mPtrVoENetwork = VoENetwork::GetInterface(mVoiceEngine))) { CSFLogError(logTag, "%s Unable to initialize VoENetwork", __FUNCTION__); return kMediaConduitSessionNotInited; } if(!(mPtrVoECodec = VoECodec::GetInterface(mVoiceEngine))) { CSFLogError(logTag, "%s Unable to initialize VoEBCodec", __FUNCTION__); return kMediaConduitSessionNotInited; } if(!(mPtrVoEProcessing = VoEAudioProcessing::GetInterface(mVoiceEngine))) { CSFLogError(logTag, "%s Unable to initialize VoEProcessing", __FUNCTION__); return kMediaConduitSessionNotInited; } if(!(mPtrVoEXmedia = VoEExternalMedia::GetInterface(mVoiceEngine))) { CSFLogError(logTag, "%s Unable to initialize VoEExternalMedia", __FUNCTION__); return kMediaConduitSessionNotInited; } if (other) { mChannel = other->mChannel; } else { // init the engine with our audio device layer if(mPtrVoEBase->Init() == -1) { CSFLogError(logTag, "%s VoiceEngine Base Not Initialized", __FUNCTION__); return kMediaConduitSessionNotInited; } if( (mChannel = mPtrVoEBase->CreateChannel()) == -1) { CSFLogError(logTag, "%s VoiceEngine Channel creation failed",__FUNCTION__); return kMediaConduitChannelError; } CSFLogDebug(logTag, "%s Channel Created %d ",__FUNCTION__, mChannel); if(mPtrVoENetwork->RegisterExternalTransport(mChannel, *this) == -1) { CSFLogError(logTag, "%s VoiceEngine, External Transport Failed",__FUNCTION__); return kMediaConduitTransportRegistrationFail; } if(mPtrVoEXmedia->SetExternalRecordingStatus(true) == -1) { CSFLogError(logTag, "%s SetExternalRecordingStatus Failed %d",__FUNCTION__, mPtrVoEBase->LastError()); return kMediaConduitExternalPlayoutError; } if(mPtrVoEXmedia->SetExternalPlayoutStatus(true) == -1) { CSFLogError(logTag, "%s SetExternalPlayoutStatus Failed %d ",__FUNCTION__, mPtrVoEBase->LastError()); return kMediaConduitExternalRecordingError; } CSFLogDebug(logTag , "%s AudioSessionConduit Initialization Done (%p)",__FUNCTION__, this); } return kMediaConduitNoError; }
void nsPicoService::Init() { MOZ_ASSERT(!NS_IsMainThread()); MOZ_ASSERT(!mInitialized); if (!sPicoApi.Init()) { NS_WARNING("Failed to initialize pico library"); return; } // Use environment variable, or default android path nsAutoCString langPath(PR_GetEnv("PICO_LANG_PATH")); if (langPath.IsEmpty()) { langPath.AssignLiteral(PICO_LANG_PATH); } nsCOMPtr<nsIFile> voicesDir; NS_NewNativeLocalFile(langPath, true, getter_AddRefs(voicesDir)); nsCOMPtr<nsISimpleEnumerator> dirIterator; nsresult rv = voicesDir->GetDirectoryEntries(getter_AddRefs(dirIterator)); if (NS_FAILED(rv)) { NS_WARNING(nsPrintfCString("Failed to get contents of directory: %s", langPath.get()).get()); return; } bool hasMoreElements = false; rv = dirIterator->HasMoreElements(&hasMoreElements); MOZ_ASSERT(NS_SUCCEEDED(rv)); MonitorAutoLock autoLock(mVoicesMonitor); while (hasMoreElements && NS_SUCCEEDED(rv)) { nsCOMPtr<nsISupports> supports; rv = dirIterator->GetNext(getter_AddRefs(supports)); MOZ_ASSERT(NS_SUCCEEDED(rv)); nsCOMPtr<nsIFile> voiceFile = do_QueryInterface(supports); MOZ_ASSERT(voiceFile); nsAutoCString leafName; voiceFile->GetNativeLeafName(leafName); nsAutoString lang; if (GetVoiceFileLanguage(leafName, lang)) { nsAutoString uri; uri.AssignLiteral("urn:moz-tts:pico:"); uri.Append(lang); bool found = false; PicoVoice* voice = mVoices.GetWeak(uri, &found); if (!found) { voice = new PicoVoice(lang); mVoices.Put(uri, voice); } // Each voice consists of two lingware files: A language resource file, // suffixed by _ta.bin, and a speaker resource file, suffixed by _sb.bin. // We currently assume that there is a pair of files for each language. if (StringEndsWith(leafName, NS_LITERAL_CSTRING("_ta.bin"))) { rv = voiceFile->GetPersistentDescriptor(voice->mTaFile); MOZ_ASSERT(NS_SUCCEEDED(rv)); } else if (StringEndsWith(leafName, NS_LITERAL_CSTRING("_sg.bin"))) { rv = voiceFile->GetPersistentDescriptor(voice->mSgFile); MOZ_ASSERT(NS_SUCCEEDED(rv)); } } rv = dirIterator->HasMoreElements(&hasMoreElements); } NS_DispatchToMainThread(NewRunnableMethod("nsPicoService::RegisterVoices", this, &nsPicoService::RegisterVoices)); }
int test_validatechain_NB(int argc, char *argv[]){ PKIX_ValidateParams *valParams = NULL; PKIX_ValidateResult *valResult = NULL; PKIX_UInt32 actualMinorVersion; PKIX_UInt32 j = 0; PKIX_UInt32 k = 0; PKIX_UInt32 chainLength = 0; PKIX_Boolean testValid = PKIX_TRUE; PKIX_List *chainCerts = NULL; PKIX_PL_Cert *dirCert = NULL; char *dirCertName = NULL; char *anchorCertName = NULL; char *dirName = NULL; PKIX_UInt32 certIndex = 0; PKIX_UInt32 anchorIndex = 0; PKIX_UInt32 checkerIndex = 0; PKIX_Boolean revChecking = PKIX_FALSE; PKIX_List *checkers = NULL; PRPollDesc *pollDesc = NULL; PRErrorCode errorCode = 0; PKIX_PL_Socket *socket = NULL; char *ldapName = NULL; PKIX_VerifyNode *verifyTree = NULL; PKIX_PL_String *verifyString = NULL; PKIX_List *loggers = NULL; PKIX_Logger *logger = NULL; char *logging = NULL; PKIX_PL_String *component = NULL; PKIX_TEST_STD_VARS(); if (argc < 5) { printUsage(); return (0); } startTests("ValidateChain_NB"); PKIX_TEST_EXPECT_NO_ERROR( PKIX_PL_NssContext_Create(0, PKIX_FALSE, NULL, &plContext)); /* ENE = expect no error; EE = expect error */ if (PORT_Strcmp(argv[2+j], "ENE") == 0) { testValid = PKIX_TRUE; } else if (PORT_Strcmp(argv[2+j], "EE") == 0) { testValid = PKIX_FALSE; } else { printUsage(); return (0); } subTest(argv[1+j]); dirName = argv[3+j]; chainLength = argc - j - 5; PKIX_TEST_EXPECT_NO_ERROR(PKIX_List_Create(&chainCerts, plContext)); for (k = 0; k < chainLength; k++){ dirCert = createCert(dirName, argv[5+k+j], plContext); PKIX_TEST_EXPECT_NO_ERROR (PKIX_List_AppendItem (chainCerts, (PKIX_PL_Object *)dirCert, plContext)); PKIX_TEST_DECREF_BC(dirCert); } valParams = createValidateParams (dirName, argv[4+j], NULL, NULL, NULL, PKIX_FALSE, PKIX_FALSE, PKIX_FALSE, PKIX_FALSE, chainCerts, plContext); ldapName = PR_GetEnv("LDAP"); /* Is LDAP set in the environment? */ if ((ldapName == NULL) || (*ldapName == '\0')) { testError("LDAP not set in environment"); goto cleanup; } pkixTestErrorResult = pkix_pl_Socket_CreateByName (PKIX_FALSE, /* isServer */ PR_SecondsToInterval(30), /* try 30 secs for connect */ ldapName, &errorCode, &socket, plContext); if (pkixTestErrorResult != NULL) { PKIX_PL_Object_DecRef ((PKIX_PL_Object *)pkixTestErrorResult, plContext); pkixTestErrorResult = NULL; testError("Unable to connect to LDAP Server"); goto cleanup; } PKIX_TEST_DECREF_BC(socket); testSetupCertStore(valParams, ldapName); logging = PR_GetEnv("LOGGING"); /* Is LOGGING set in the environment? */ if ((logging != NULL) && (*logging != '\0')) { PKIX_TEST_EXPECT_NO_ERROR (PKIX_List_Create(&loggers, plContext)); testLogErrors (PKIX_VALIDATE_ERROR, 2, loggers, plContext); testLogErrors (PKIX_CERTCHAINCHECKER_ERROR, 2, loggers, plContext); testLogErrors (PKIX_LDAPDEFAULTCLIENT_ERROR, 2, loggers, plContext); testLogErrors (PKIX_CERTSTORE_ERROR, 2, loggers, plContext); PKIX_TEST_EXPECT_NO_ERROR(PKIX_SetLoggers(loggers, plContext)); } pkixTestErrorResult = PKIX_ValidateChain_NB (valParams, &certIndex, &anchorIndex, &checkerIndex, &revChecking, &checkers, (void **)&pollDesc, &valResult, &verifyTree, plContext); while (pollDesc != NULL) { if (PR_Poll(pollDesc, 1, 0) < 0) { testError("PR_Poll failed"); } pkixTestErrorResult = PKIX_ValidateChain_NB (valParams, &certIndex, &anchorIndex, &checkerIndex, &revChecking, &checkers, (void **)&pollDesc, &valResult, &verifyTree, plContext); } if (pkixTestErrorResult) { if (testValid == PKIX_FALSE) { /* EE */ (void) printf("EXPECTED ERROR RECEIVED!\n"); } else { /* ENE */ testError("UNEXPECTED ERROR RECEIVED"); } PKIX_TEST_DECREF_BC(pkixTestErrorResult); } else { if (testValid == PKIX_TRUE) { /* ENE */ (void) printf("EXPECTED NON-ERROR RECEIVED!\n"); } else { /* EE */ (void) printf("UNEXPECTED NON-ERROR RECEIVED!\n"); } } cleanup: if (verifyTree) { PKIX_TEST_EXPECT_NO_ERROR(PKIX_PL_Object_ToString ((PKIX_PL_Object*)verifyTree, &verifyString, plContext)); (void) printf("verifyTree is\n%s\n", verifyString->escAsciiString); } PKIX_TEST_DECREF_AC(verifyString); PKIX_TEST_DECREF_AC(verifyTree); PKIX_TEST_DECREF_AC(checkers); PKIX_TEST_DECREF_AC(chainCerts); PKIX_TEST_DECREF_AC(valParams); PKIX_TEST_DECREF_AC(valResult); PKIX_Shutdown(plContext); PKIX_TEST_RETURN(); endTests("ValidateChain_NB"); return (0); }
int StartServer(const char *nssCertDBDir, SSLSNISocketConfig sniSocketConfig, void *sniSocketConfigArg) { const char *debugLevel = PR_GetEnv("MOZ_TLS_SERVER_DEBUG_LEVEL"); if (debugLevel) { int level = atoi(debugLevel); switch (level) { case DEBUG_ERRORS: gDebugLevel = DEBUG_ERRORS; break; case DEBUG_WARNINGS: gDebugLevel = DEBUG_WARNINGS; break; case DEBUG_VERBOSE: gDebugLevel = DEBUG_VERBOSE; break; default: PrintPRError("invalid MOZ_TLS_SERVER_DEBUG_LEVEL"); return 1; } } const char *callbackPort = PR_GetEnv("MOZ_TLS_SERVER_CALLBACK_PORT"); if (callbackPort) { gCallbackPort = atoi(callbackPort); } if (InitializeNSS(nssCertDBDir) != SECSuccess) { PR_fprintf(PR_STDERR, "InitializeNSS failed"); return 1; } if (NSS_SetDomesticPolicy() != SECSuccess) { PrintPRError("NSS_SetDomesticPolicy failed"); return 1; } if (SSL_ConfigServerSessionIDCache(0, 0, 0, nullptr) != SECSuccess) { PrintPRError("SSL_ConfigServerSessionIDCache failed"); return 1; } UniquePRFileDesc serverSocket(PR_NewTCPSocket()); if (!serverSocket) { PrintPRError("PR_NewTCPSocket failed"); return 1; } PRSocketOptionData socketOption; socketOption.option = PR_SockOpt_Reuseaddr; socketOption.value.reuse_addr = true; PR_SetSocketOption(serverSocket.get(), &socketOption); PRNetAddr serverAddr; PR_InitializeNetAddr(PR_IpAddrLoopback, LISTEN_PORT, &serverAddr); if (PR_Bind(serverSocket.get(), &serverAddr) != PR_SUCCESS) { PrintPRError("PR_Bind failed"); return 1; } if (PR_Listen(serverSocket.get(), 1) != PR_SUCCESS) { PrintPRError("PR_Listen failed"); return 1; } UniquePRFileDesc rawModelSocket(PR_NewTCPSocket()); if (!rawModelSocket) { PrintPRError("PR_NewTCPSocket failed for rawModelSocket"); return 1; } UniquePRFileDesc modelSocket(SSL_ImportFD(nullptr, rawModelSocket.release())); if (!modelSocket) { PrintPRError("SSL_ImportFD of rawModelSocket failed"); return 1; } if (SSL_SNISocketConfigHook(modelSocket.get(), sniSocketConfig, sniSocketConfigArg) != SECSuccess) { PrintPRError("SSL_SNISocketConfigHook failed"); return 1; } // We have to configure the server with a certificate, but it's not one // we're actually going to end up using. In the SNI callback, we pick // the right certificate for the connection. if (ConfigSecureServerWithNamedCert(modelSocket.get(), DEFAULT_CERT_NICKNAME, nullptr, nullptr) != SECSuccess) { return 1; } if (gCallbackPort != 0) { if (DoCallback()) { return 1; } } while (true) { PRNetAddr clientAddr; PRFileDesc* clientSocket = PR_Accept(serverSocket.get(), &clientAddr, PR_INTERVAL_NO_TIMEOUT); HandleConnection(clientSocket, modelSocket); } return 0; }
//---------------------------------------------------------------------------------------- // GetProductDirectory - Gets the directory which contains the application data folder // // UNIX : ~/.mozilla/ // WIN : <Application Data folder on user's machine>\Mozilla // Mac : :Documents:Mozilla: //---------------------------------------------------------------------------------------- NS_METHOD nsAppFileLocationProvider::GetProductDirectory(nsIFile** aLocalFile, bool aLocal) { if (NS_WARN_IF(!aLocalFile)) { return NS_ERROR_INVALID_ARG; } nsresult rv; bool exists; nsCOMPtr<nsIFile> localDir; #if defined(MOZ_WIDGET_COCOA) FSRef fsRef; OSType folderType = aLocal ? (OSType)kCachedDataFolderType : (OSType)kDomainLibraryFolderType; OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef); if (err) { return NS_ERROR_FAILURE; } NS_NewLocalFile(EmptyString(), true, getter_AddRefs(localDir)); if (!localDir) { return NS_ERROR_FAILURE; } nsCOMPtr<nsILocalFileMac> localDirMac(do_QueryInterface(localDir)); rv = localDirMac->InitWithFSRef(&fsRef); if (NS_FAILED(rv)) { return rv; } #elif defined(XP_WIN) nsCOMPtr<nsIProperties> directoryService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) { return rv; } const char* prop = aLocal ? NS_WIN_LOCAL_APPDATA_DIR : NS_WIN_APPDATA_DIR; rv = directoryService->Get(prop, NS_GET_IID(nsIFile), getter_AddRefs(localDir)); if (NS_FAILED(rv)) { return rv; } #elif defined(XP_UNIX) rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), true, getter_AddRefs(localDir)); if (NS_FAILED(rv)) { return rv; } #else #error dont_know_how_to_get_product_dir_on_your_platform #endif rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR); if (NS_FAILED(rv)) { return rv; } rv = localDir->Exists(&exists); if (NS_SUCCEEDED(rv) && !exists) { rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0700); } if (NS_FAILED(rv)) { return rv; } localDir.forget(aLocalFile); return rv; }
nsresult GetSpecialSystemDirectory(SystemDirectories aSystemSystemDirectory, nsIFile** aFile) { #if defined(XP_WIN) WCHAR path[MAX_PATH]; #else char path[MAXPATHLEN]; #endif switch (aSystemSystemDirectory) { case OS_CurrentWorkingDirectory: #if defined(XP_WIN) if (!_wgetcwd(path, MAX_PATH)) return NS_ERROR_FAILURE; return NS_NewLocalFile(nsDependentString(path), true, aFile); #else if(!getcwd(path, MAXPATHLEN)) return NS_ERROR_FAILURE; #endif #if !defined(XP_WIN) return NS_NewNativeLocalFile(nsDependentCString(path), true, aFile); #endif case OS_DriveDirectory: #if defined (XP_WIN) { int32_t len = ::GetWindowsDirectoryW(path, MAX_PATH); if (len == 0) break; if (path[1] == PRUnichar(':') && path[2] == PRUnichar('\\')) path[3] = 0; return NS_NewLocalFile(nsDependentString(path), true, aFile); } #else return NS_NewNativeLocalFile(nsDependentCString("/"), true, aFile); #endif case OS_TemporaryDirectory: #if defined (XP_WIN) { DWORD len = ::GetTempPathW(MAX_PATH, path); if (len == 0) break; return NS_NewLocalFile(nsDependentString(path, len), true, aFile); } #elif defined(MOZ_WIDGET_COCOA) { return GetOSXFolderType(kUserDomain, kTemporaryFolderType, aFile); } #elif defined(XP_UNIX) { static const char *tPath = nullptr; if (!tPath) { tPath = PR_GetEnv("PANDORATMP"); if (!tPath) { tPath = PR_GetEnv("TMPDIR"); if (!tPath || !*tPath) { tPath = PR_GetEnv("TMP"); if (!tPath || !*tPath) { tPath = PR_GetEnv("TEMP"); if (!tPath || !*tPath) { tPath = "/tmp/"; } } } } } return NS_NewNativeLocalFile(nsDependentCString(tPath), true, aFile); } #else break; #endif #if defined (XP_WIN) case Win_SystemDirectory: { int32_t len = ::GetSystemDirectoryW(path, MAX_PATH); // Need enough space to add the trailing backslash if (!len || len > MAX_PATH - 2) break; path[len] = L'\\'; path[++len] = L'\0'; return NS_NewLocalFile(nsDependentString(path, len), true, aFile); } case Win_WindowsDirectory: { int32_t len = ::GetWindowsDirectoryW(path, MAX_PATH); // Need enough space to add the trailing backslash if (!len || len > MAX_PATH - 2) break; path[len] = L'\\'; path[++len] = L'\0'; return NS_NewLocalFile(nsDependentString(path, len), true, aFile); } case Win_ProgramFiles: { return GetWindowsFolder(CSIDL_PROGRAM_FILES, aFile); } case Win_HomeDirectory: { nsresult rv = GetWindowsFolder(CSIDL_PROFILE, aFile); if (NS_SUCCEEDED(rv)) return rv; int32_t len; if ((len = ::GetEnvironmentVariableW(L"HOME", path, MAX_PATH)) > 0) { // Need enough space to add the trailing backslash if (len > MAX_PATH - 2) break; path[len] = L'\\'; path[++len] = L'\0'; rv = NS_NewLocalFile(nsDependentString(path, len), true, aFile); if (NS_SUCCEEDED(rv)) return rv; } len = ::GetEnvironmentVariableW(L"HOMEDRIVE", path, MAX_PATH); if (0 < len && len < MAX_PATH) { WCHAR temp[MAX_PATH]; DWORD len2 = ::GetEnvironmentVariableW(L"HOMEPATH", temp, MAX_PATH); if (0 < len2 && len + len2 < MAX_PATH) wcsncat(path, temp, len2); len = wcslen(path); // Need enough space to add the trailing backslash if (len > MAX_PATH - 2) break; path[len] = L'\\'; path[++len] = L'\0'; return NS_NewLocalFile(nsDependentString(path, len), true, aFile); } } case Win_Desktop: { return GetWindowsFolder(CSIDL_DESKTOP, aFile); } case Win_Programs: { return GetWindowsFolder(CSIDL_PROGRAMS, aFile); } case Win_Downloads: { // Defined in KnownFolders.h. GUID folderid_downloads = {0x374de290, 0x123f, 0x4565, {0x91, 0x64, 0x39, 0xc4, 0x92, 0x5e, 0x46, 0x7b}}; nsresult rv = GetKnownFolder(&folderid_downloads, aFile); // On WinXP, there is no downloads folder, default // to 'Desktop'. if(NS_ERROR_FAILURE == rv) { rv = GetWindowsFolder(CSIDL_DESKTOP, aFile); } return rv; } case Win_Controls: { return GetWindowsFolder(CSIDL_CONTROLS, aFile); } case Win_Printers: { return GetWindowsFolder(CSIDL_PRINTERS, aFile); } case Win_Personal: { return GetWindowsFolder(CSIDL_PERSONAL, aFile); } case Win_Favorites: { return GetWindowsFolder(CSIDL_FAVORITES, aFile); } case Win_Startup: { return GetWindowsFolder(CSIDL_STARTUP, aFile); } case Win_Recent: { return GetWindowsFolder(CSIDL_RECENT, aFile); } case Win_Sendto: { return GetWindowsFolder(CSIDL_SENDTO, aFile); } case Win_Bitbucket: { return GetWindowsFolder(CSIDL_BITBUCKET, aFile); } case Win_Startmenu: { return GetWindowsFolder(CSIDL_STARTMENU, aFile); } case Win_Desktopdirectory: { return GetWindowsFolder(CSIDL_DESKTOPDIRECTORY, aFile); } case Win_Drives: { return GetWindowsFolder(CSIDL_DRIVES, aFile); } case Win_Network: { return GetWindowsFolder(CSIDL_NETWORK, aFile); } case Win_Nethood: { return GetWindowsFolder(CSIDL_NETHOOD, aFile); } case Win_Fonts: { return GetWindowsFolder(CSIDL_FONTS, aFile); } case Win_Templates: { return GetWindowsFolder(CSIDL_TEMPLATES, aFile); } case Win_Common_Startmenu: { return GetWindowsFolder(CSIDL_COMMON_STARTMENU, aFile); } case Win_Common_Programs: { return GetWindowsFolder(CSIDL_COMMON_PROGRAMS, aFile); } case Win_Common_Startup: { return GetWindowsFolder(CSIDL_COMMON_STARTUP, aFile); } case Win_Common_Desktopdirectory: { return GetWindowsFolder(CSIDL_COMMON_DESKTOPDIRECTORY, aFile); } case Win_Common_AppData: { return GetWindowsFolder(CSIDL_COMMON_APPDATA, aFile); } case Win_Printhood: { return GetWindowsFolder(CSIDL_PRINTHOOD, aFile); } case Win_Cookies: { return GetWindowsFolder(CSIDL_COOKIES, aFile); } case Win_Appdata: { nsresult rv = GetWindowsFolder(CSIDL_APPDATA, aFile); if (NS_FAILED(rv)) rv = GetRegWindowsAppDataFolder(false, aFile); return rv; } case Win_LocalAppdata: { nsresult rv = GetWindowsFolder(CSIDL_LOCAL_APPDATA, aFile); if (NS_FAILED(rv)) rv = GetRegWindowsAppDataFolder(true, aFile); return rv; } case Win_Documents: { return GetLibrarySaveToPath(CSIDL_MYDOCUMENTS, FOLDERID_DocumentsLibrary, aFile); } case Win_Pictures: { return GetLibrarySaveToPath(CSIDL_MYPICTURES, FOLDERID_PicturesLibrary, aFile); } case Win_Music: { return GetLibrarySaveToPath(CSIDL_MYMUSIC, FOLDERID_MusicLibrary, aFile); } case Win_Videos: { return GetLibrarySaveToPath(CSIDL_MYVIDEO, FOLDERID_VideosLibrary, aFile); } #endif // XP_WIN #if defined(XP_UNIX) case Unix_LocalDirectory: return NS_NewNativeLocalFile(nsDependentCString("/usr/local/netscape/"), true, aFile); case Unix_LibDirectory: return NS_NewNativeLocalFile(nsDependentCString("/usr/local/lib/netscape/"), true, aFile); case Unix_HomeDirectory: return GetUnixHomeDir(aFile); case Unix_XDG_Desktop: case Unix_XDG_Documents: case Unix_XDG_Download: case Unix_XDG_Music: case Unix_XDG_Pictures: case Unix_XDG_PublicShare: case Unix_XDG_Templates: case Unix_XDG_Videos: return GetUnixXDGUserDirectory(aSystemSystemDirectory, aFile); #endif // XP_UNIX default: break; } return NS_ERROR_NOT_AVAILABLE; }
nsresult ShutdownXPCOM(nsIServiceManager* aServMgr) { // Make sure the hang monitor is enabled for shutdown. HangMonitor::NotifyActivity(); if (!NS_IsMainThread()) { NS_RUNTIMEABORT("Shutdown on wrong thread"); } nsresult rv; nsCOMPtr<nsISimpleEnumerator> moduleLoaders; // Notify observers of xpcom shutting down { // Block it so that the COMPtr will get deleted before we hit // servicemanager shutdown nsCOMPtr<nsIThread> thread = do_GetCurrentThread(); if (NS_WARN_IF(!thread)) { return NS_ERROR_UNEXPECTED; } RefPtr<nsObserverService> observerService; CallGetService("@mozilla.org/observer-service;1", (nsObserverService**)getter_AddRefs(observerService)); if (observerService) { mozilla::KillClearOnShutdown(ShutdownPhase::WillShutdown); observerService->NotifyObservers(nullptr, NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID, nullptr); nsCOMPtr<nsIServiceManager> mgr; rv = NS_GetServiceManager(getter_AddRefs(mgr)); if (NS_SUCCEEDED(rv)) { mozilla::KillClearOnShutdown(ShutdownPhase::Shutdown); observerService->NotifyObservers(mgr, NS_XPCOM_SHUTDOWN_OBSERVER_ID, nullptr); } } // This must happen after the shutdown of media and widgets, which // are triggered by the NS_XPCOM_SHUTDOWN_OBSERVER_ID notification. NS_ProcessPendingEvents(thread); gfxPlatform::ShutdownLayersIPC(); mozilla::scache::StartupCache::DeleteSingleton(); if (observerService) { mozilla::KillClearOnShutdown(ShutdownPhase::ShutdownThreads); observerService->NotifyObservers(nullptr, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID, nullptr); } gXPCOMThreadsShutDown = true; NS_ProcessPendingEvents(thread); // Shutdown the timer thread and all timers that might still be alive before // shutting down the component manager nsTimerImpl::Shutdown(); NS_ProcessPendingEvents(thread); // Shutdown all remaining threads. This method does not return until // all threads created using the thread manager (with the exception of // the main thread) have exited. nsThreadManager::get()->Shutdown(); NS_ProcessPendingEvents(thread); HangMonitor::NotifyActivity(); // Late-write checks needs to find the profile directory, so it has to // be initialized before mozilla::services::Shutdown or (because of // xpcshell tests replacing the service) modules being unloaded. mozilla::InitLateWriteChecks(); // We save the "xpcom-shutdown-loaders" observers to notify after // the observerservice is gone. if (observerService) { mozilla::KillClearOnShutdown(ShutdownPhase::ShutdownLoaders); observerService->EnumerateObservers(NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID, getter_AddRefs(moduleLoaders)); observerService->Shutdown(); } } // Free ClearOnShutdown()'ed smart pointers. This needs to happen *after* // we've finished notifying observers of XPCOM shutdown, because shutdown // observers themselves might call ClearOnShutdown(). mozilla::KillClearOnShutdown(ShutdownPhase::ShutdownFinal); // XPCOM is officially in shutdown mode NOW // Set this only after the observers have been notified as this // will cause servicemanager to become inaccessible. mozilla::services::Shutdown(); // We may have AddRef'd for the caller of NS_InitXPCOM, so release it // here again: NS_IF_RELEASE(aServMgr); // Shutdown global servicemanager if (nsComponentManagerImpl::gComponentManager) { nsComponentManagerImpl::gComponentManager->FreeServices(); } // Release the directory service nsDirectoryService::gService = nullptr; free(gGREBinPath); gGREBinPath = nullptr; if (moduleLoaders) { bool more; nsCOMPtr<nsISupports> el; while (NS_SUCCEEDED(moduleLoaders->HasMoreElements(&more)) && more) { moduleLoaders->GetNext(getter_AddRefs(el)); // Don't worry about weak-reference observers here: there is // no reason for weak-ref observers to register for // xpcom-shutdown-loaders // FIXME: This can cause harmless writes from sqlite committing // log files. We have to ignore them before we can move // the mozilla::PoisonWrite call before this point. See bug // 834945 for the details. nsCOMPtr<nsIObserver> obs(do_QueryInterface(el)); if (obs) { obs->Observe(nullptr, NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID, nullptr); } } moduleLoaders = nullptr; } bool shutdownCollect; #ifdef NS_FREE_PERMANENT_DATA shutdownCollect = true; #else shutdownCollect = !!PR_GetEnv("MOZ_CC_RUN_DURING_SHUTDOWN"); #endif nsCycleCollector_shutdown(shutdownCollect); PROFILER_MARKER("Shutdown xpcom"); // If we are doing any shutdown checks, poison writes. if (gShutdownChecks != SCM_NOTHING) { #ifdef XP_MACOSX mozilla::OnlyReportDirtyWrites(); #endif /* XP_MACOSX */ mozilla::BeginLateWriteChecks(); } // Shutdown nsLocalFile string conversion NS_ShutdownLocalFile(); #ifdef XP_UNIX NS_ShutdownNativeCharsetUtils(); #endif // Shutdown xpcom. This will release all loaders and cause others holding // a refcount to the component manager to release it. if (nsComponentManagerImpl::gComponentManager) { rv = (nsComponentManagerImpl::gComponentManager)->Shutdown(); NS_ASSERTION(NS_SUCCEEDED(rv), "Component Manager shutdown failed."); } else { NS_WARNING("Component Manager was never created ..."); } #ifdef MOZ_ENABLE_PROFILER_SPS // In optimized builds we don't do shutdown collections by default, so // uncollected (garbage) objects may keep the nsXPConnect singleton alive, // and its XPCJSRuntime along with it. However, we still destroy various // bits of state in JS_ShutDown(), so we need to make sure the profiler // can't access them when it shuts down. This call nulls out the // JS pseudo-stack's internal reference to the main thread JSRuntime, // duplicating the call in XPCJSRuntime::~XPCJSRuntime() in case that // never fired. if (PseudoStack* stack = mozilla_get_pseudo_stack()) { stack->sampleRuntime(nullptr); } #endif // Shut down the JS engine. JS_ShutDown(); // Release our own singletons // Do this _after_ shutting down the component manager, because the // JS component loader will use XPConnect to call nsIModule::canUnload, // and that will spin up the InterfaceInfoManager again -- bad mojo XPTInterfaceInfoManager::FreeInterfaceInfoManager(); // Finally, release the component manager last because it unloads the // libraries: if (nsComponentManagerImpl::gComponentManager) { nsrefcnt cnt; NS_RELEASE2(nsComponentManagerImpl::gComponentManager, cnt); NS_ASSERTION(cnt == 0, "Component Manager being held past XPCOM shutdown."); } nsComponentManagerImpl::gComponentManager = nullptr; nsCategoryManager::Destroy(); NS_ShutdownAtomTable(); NS_IF_RELEASE(gDebug); delete sIOThread; sIOThread = nullptr; delete sMessageLoop; sMessageLoop = nullptr; if (sCommandLineWasInitialized) { CommandLine::Terminate(); sCommandLineWasInitialized = false; } delete sExitManager; sExitManager = nullptr; Omnijar::CleanUp(); HangMonitor::Shutdown(); delete sMainHangMonitor; sMainHangMonitor = nullptr; BackgroundHangMonitor::Shutdown(); profiler_shutdown(); NS_LogTerm(); #if defined(MOZ_WIDGET_GONK) // This _exit(0) call is intended to be temporary, to get shutdown leak // checking working on non-B2G platforms. // On debug B2G, the child process crashes very late. Instead, just // give up so at least we exit cleanly. See bug 1071866. if (XRE_IsContentProcess()) { NS_WARNING("Exiting child process early!"); _exit(0); } #endif return NS_OK; }
static nsresult GetUnixXDGUserDirectory(SystemDirectories aSystemDirectory, nsIFile** aFile) { char *dir = xdg_user_dir_lookup (xdg_user_dirs + xdg_user_dir_offsets[aSystemDirectory - Unix_XDG_Desktop]); nsresult rv; nsCOMPtr<nsIFile> file; if (dir) { rv = NS_NewNativeLocalFile(nsDependentCString(dir), true, getter_AddRefs(file)); free(dir); } else if (Unix_XDG_Desktop == aSystemDirectory) { // for the XDG desktop dir, fall back to HOME/Desktop // (for historical compatibility) rv = GetUnixHomeDir(getter_AddRefs(file)); if (NS_FAILED(rv)) return rv; rv = file->AppendNative(NS_LITERAL_CSTRING("Desktop")); } #if defined(MOZ_PLATFORM_MAEMO) // "MYDOCSDIR" is exported to point to "/home/user/MyDocs" in maemo. else if (Unix_XDG_Documents == aSystemDirectory) { char *myDocs = PR_GetEnv("MYDOCSDIR"); if (!myDocs || !*myDocs) return NS_ERROR_FAILURE; rv = NS_NewNativeLocalFile(nsDependentCString(myDocs), true, getter_AddRefs(file)); if (NS_FAILED(rv)) return rv; rv = file->AppendNative(NS_LITERAL_CSTRING(".documents")); } #endif else { // no fallback for the other XDG dirs rv = NS_ERROR_FAILURE; } if (NS_FAILED(rv)) return rv; bool exists; rv = file->Exists(&exists); if (NS_FAILED(rv)) return rv; if (!exists) { rv = file->Create(nsIFile::DIRECTORY_TYPE, 0755); if (NS_FAILED(rv)) return rv; } *aFile = nullptr; file.swap(*aFile); return NS_OK; }
void GfxInfo::GetData() { // to understand this function, see bug 639842. We retrieve the OpenGL driver information in a // separate process to protect against bad drivers. // if glxtest_pipe == 0, that means that we already read the information if (!glxtest_pipe) return; enum { buf_size = 1024 }; char buf[buf_size]; ssize_t bytesread = read(glxtest_pipe, &buf, buf_size-1); // -1 because we'll append a zero close(glxtest_pipe); glxtest_pipe = 0; // bytesread < 0 would mean that the above read() call failed. This should never happen. if (bytesread < 0) bytesread = 0; // let buf be a zero-terminated string buf[bytesread] = 0; // Wait for the glxtest process to finish. This serves 2 purposes: // * avoid having a zombie glxtest process laying around // * get the glxtest process status info. int glxtest_status = 0; bool wait_for_glxtest_process = true; bool waiting_for_glxtest_process_failed = false; while(wait_for_glxtest_process) { wait_for_glxtest_process = false; if (waitpid(glxtest_pid, &glxtest_status, 0) == -1) { if (errno == EINTR) wait_for_glxtest_process = true; else waiting_for_glxtest_process_failed = true; } } bool exited_with_error_code = !waiting_for_glxtest_process_failed && WIFEXITED(glxtest_status) && WEXITSTATUS(glxtest_status) != EXIT_SUCCESS; bool received_signal = !waiting_for_glxtest_process_failed && WIFSIGNALED(glxtest_status); bool error = waiting_for_glxtest_process_failed || exited_with_error_code || received_signal; nsCString *stringToFill = nsnull; char *bufptr = buf; if (!error) { while(true) { char *line = NS_strtok("\n", &bufptr); if (!line) break; if (stringToFill) { stringToFill->Assign(line); stringToFill = nsnull; } else if(!strcmp(line, "VENDOR")) stringToFill = &mVendor; else if(!strcmp(line, "RENDERER")) stringToFill = &mRenderer; else if(!strcmp(line, "VERSION")) stringToFill = &mVersion; } } const char *spoofedVendor = PR_GetEnv("MOZ_GFX_SPOOF_GL_VENDOR"); if (spoofedVendor) mVendor.Assign(spoofedVendor); const char *spoofedRenderer = PR_GetEnv("MOZ_GFX_SPOOF_GL_RENDERER"); if (spoofedRenderer) mRenderer.Assign(spoofedRenderer); const char *spoofedVersion = PR_GetEnv("MOZ_GFX_SPOOF_GL_VERSION"); if (spoofedVersion) mVersion.Assign(spoofedVersion); if (error || mVendor.IsEmpty() || mRenderer.IsEmpty() || mVersion.IsEmpty()) { mAdapterDescription.AppendLiteral("GLXtest process failed"); if (waiting_for_glxtest_process_failed) mAdapterDescription.AppendLiteral(" (waitpid failed)"); if (exited_with_error_code) mAdapterDescription.AppendPrintf(" (exited with status %d)", WEXITSTATUS(glxtest_status)); if (received_signal) mAdapterDescription.AppendPrintf(" (received signal %d)", WTERMSIG(glxtest_status)); if (bytesread) { mAdapterDescription.AppendLiteral(": "); mAdapterDescription.Append(nsDependentCString(buf)); mAdapterDescription.AppendLiteral("\n"); } #ifdef MOZ_CRASHREPORTER CrashReporter::AppendAppNotesToCrashReport(mAdapterDescription); #endif return; } mAdapterDescription.Append(mVendor); mAdapterDescription.AppendLiteral(" -- "); mAdapterDescription.Append(mRenderer); nsCAutoString note; note.Append("OpenGL: "); note.Append(mAdapterDescription); note.Append(" -- "); note.Append(mVersion); note.Append("\n"); #ifdef MOZ_CRASHREPORTER CrashReporter::AppendAppNotesToCrashReport(note); #endif // determine driver type (vendor) and where in the version string // the actual driver version numbers should be expected to be found (whereToReadVersionNumbers) const char *whereToReadVersionNumbers = nsnull; const char *Mesa_in_version_string = strstr(mVersion.get(), "Mesa"); if (Mesa_in_version_string) { mIsMesa = true; // with Mesa, the version string contains "Mesa major.minor" and that's all the version information we get: // there is no actual driver version info. whereToReadVersionNumbers = Mesa_in_version_string + strlen("Mesa"); } else if (strstr(mVendor.get(), "NVIDIA Corporation")) { mIsNVIDIA = true; // with the NVIDIA driver, the version string contains "NVIDIA major.minor" // note that here the vendor and version strings behave differently, that's why we don't put this above // alongside Mesa_in_version_string. const char *NVIDIA_in_version_string = strstr(mVersion.get(), "NVIDIA"); if (NVIDIA_in_version_string) whereToReadVersionNumbers = NVIDIA_in_version_string + strlen("NVIDIA"); } else if (strstr(mVendor.get(), "ATI Technologies Inc")) { mIsFGLRX = true; // with the FGLRX driver, the version string only gives a OpenGL version :/ so let's return that. // that can at least give a rough idea of how old the driver is. whereToReadVersionNumbers = mVersion.get(); } // read major.minor version numbers if (whereToReadVersionNumbers) { // copy into writable buffer, for tokenization strncpy(buf, whereToReadVersionNumbers, buf_size); bufptr = buf; // now try to read major.minor version numbers. In case of failure, gracefully exit: these numbers have // been initialized as 0 anyways char *token = NS_strtok(".", &bufptr); if (token) { mMajorVersion = strtol(token, 0, 10); token = NS_strtok(".", &bufptr); if (token) mMinorVersion = strtol(token, 0, 10); } } }
void WriteConsoleLog() { nsresult rv; nsCOMPtr<nsILocalFile> lfile; char* logFileEnv = PR_GetEnv("XRE_CONSOLE_LOG"); if (logFileEnv && *logFileEnv) { rv = XRE_GetFileFromPath(logFileEnv, getter_AddRefs(lfile)); if (NS_FAILED(rv)) return; } else { if (!gLogConsoleErrors) return; rv = gDirServiceProvider->GetUserAppDataDirectory(getter_AddRefs(lfile)); if (NS_FAILED(rv)) return; lfile->AppendNative(NS_LITERAL_CSTRING("console.log")); } PRFileDesc *file; rv = lfile->OpenNSPRFileDesc(PR_WRONLY | PR_APPEND | PR_CREATE_FILE, 0660, &file); if (NS_FAILED(rv)) return; nsCOMPtr<nsIConsoleService> csrv (do_GetService(NS_CONSOLESERVICE_CONTRACTID)); if (!csrv) { PR_Close(file); return; } nsIConsoleMessage** messages; PRUint32 mcount; rv = csrv->GetMessageArray(&messages, &mcount); if (NS_FAILED(rv)) { PR_Close(file); return; } if (mcount) { PRExplodedTime etime; PR_ExplodeTime(PR_Now(), PR_LocalTimeParameters, &etime); char datetime[512]; PR_FormatTimeUSEnglish(datetime, sizeof(datetime), "%Y-%m-%d %H:%M:%S", &etime); PR_fprintf(file, NS_LINEBREAK "*** Console log: %s ***" NS_LINEBREAK, datetime); } // From this point on, we have to release all the messages, and free // the memory allocated for the messages array. XPCOM arrays suck. nsXPIDLString msg; nsCAutoString nativemsg; for (PRUint32 i = 0; i < mcount; ++i) { rv = messages[i]->GetMessage(getter_Copies(msg)); if (NS_SUCCEEDED(rv)) { NS_CopyUnicodeToNative(msg, nativemsg); PR_fprintf(file, "%s" NS_LINEBREAK, nativemsg.get()); } NS_IF_RELEASE(messages[i]); } PR_Close(file); NS_Free(messages); }
void InstallSignalHandlers(const char *ProgramName) { PL_strncpy(_progname,ProgramName, (sizeof(_progname)-1) ); const char *gdbSleep = PR_GetEnv("MOZ_GDB_SLEEP"); if (gdbSleep && *gdbSleep) { unsigned int s; if (1 == sscanf(gdbSleep, "%u", &s)) { _gdb_sleep_duration = s; } } #if defined(CRAWL_STACK_ON_SIGSEGV) if (!getenv("XRE_NO_WINDOWS_CRASH_DIALOG")) { void (*crap_handler)(int) = GeckoProcessType_Default != XRE_GetProcessType() ? child_ah_crap_handler : ah_crap_handler; signal(SIGSEGV, crap_handler); signal(SIGILL, crap_handler); signal(SIGABRT, crap_handler); } #endif // CRAWL_STACK_ON_SIGSEGV #ifdef SA_SIGINFO /* Install a handler for floating point exceptions and disable them if they occur. */ struct sigaction sa, osa; sa.sa_flags = SA_ONSTACK | SA_RESTART | SA_SIGINFO; sa.sa_sigaction = fpehandler; sigemptyset(&sa.sa_mask); sigaction(SIGFPE, &sa, &osa); #endif if (XRE_IsContentProcess()) { /* * If the user is debugging a Gecko parent process in gdb and hits ^C to * suspend, a SIGINT signal will be sent to the child. We ignore this signal * so the child isn't killed. */ signal(SIGINT, SIG_IGN); } #if defined(DEBUG) && defined(LINUX) const char *memLimit = PR_GetEnv("MOZ_MEM_LIMIT"); if (memLimit && *memLimit) { long m = atoi(memLimit); m *= (1024*1024); struct rlimit r; r.rlim_cur = m; r.rlim_max = m; setrlimit(RLIMIT_AS, &r); } #endif #if defined(SOLARIS) #define NOFILES 512 // Boost Solaris file descriptors { struct rlimit rl; if (getrlimit(RLIMIT_NOFILE, &rl) == 0) if (rl.rlim_cur < NOFILES) { rl.rlim_cur = NOFILES; if (setrlimit(RLIMIT_NOFILE, &rl) < 0) { perror("setrlimit(RLIMIT_NOFILE)"); fprintf(stderr, "Cannot exceed hard limit for open files"); } #if defined(DEBUG) if (getrlimit(RLIMIT_NOFILE, &rl) == 0) printf("File descriptors set to %d\n", rl.rlim_cur); #endif //DEBUG } } #endif //SOLARIS #if defined(MOZ_WIDGET_GTK) && (GLIB_MAJOR_VERSION > 2 || (GLIB_MAJOR_VERSION == 2 && GLIB_MINOR_VERSION >= 6)) const char *assertString = PR_GetEnv("XPCOM_DEBUG_BREAK"); if (assertString && (!strcmp(assertString, "suspend") || !strcmp(assertString, "stack") || !strcmp(assertString, "abort") || !strcmp(assertString, "trap") || !strcmp(assertString, "break"))) { // Override the default glib logging function so we get stacks for it too. orig_log_func = g_log_set_default_handler(my_glib_log_func, nullptr); } #endif }
NS_IMETHODIMP nsAppFileLocationProvider::GetFile(const char* aProp, bool* aPersistent, nsIFile** aResult) { if (NS_WARN_IF(!aProp)) { return NS_ERROR_INVALID_ARG; } nsCOMPtr<nsIFile> localFile; nsresult rv = NS_ERROR_FAILURE; *aResult = nullptr; *aPersistent = true; #ifdef MOZ_WIDGET_COCOA FSRef fileRef; nsCOMPtr<nsILocalFileMac> macFile; #endif if (nsCRT::strcmp(aProp, NS_APP_APPLICATION_REGISTRY_DIR) == 0) { rv = GetProductDirectory(getter_AddRefs(localFile)); } else if (nsCRT::strcmp(aProp, NS_APP_APPLICATION_REGISTRY_FILE) == 0) { rv = GetProductDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) { rv = localFile->AppendNative(APP_REGISTRY_NAME); } } else if (nsCRT::strcmp(aProp, NS_APP_DEFAULTS_50_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) { rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME); } } else if (nsCRT::strcmp(aProp, NS_APP_PREF_DEFAULTS_50_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) { rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME); if (NS_SUCCEEDED(rv)) { rv = localFile->AppendRelativeNativePath(DEFAULTS_PREF_DIR_NAME); } } } else if (nsCRT::strcmp(aProp, NS_APP_USER_PROFILES_ROOT_DIR) == 0) { rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile)); } else if (nsCRT::strcmp(aProp, NS_APP_USER_PROFILES_LOCAL_ROOT_DIR) == 0) { rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile), true); } else if (nsCRT::strcmp(aProp, NS_APP_RES_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) { rv = localFile->AppendRelativeNativePath(RES_DIR_NAME); } } else if (nsCRT::strcmp(aProp, NS_APP_CHROME_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) { rv = localFile->AppendRelativeNativePath(CHROME_DIR_NAME); } } else if (nsCRT::strcmp(aProp, NS_APP_PLUGINS_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) { rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME); } } #ifdef MOZ_WIDGET_COCOA else if (nsCRT::strcmp(aProp, NS_MACOSX_USER_PLUGIN_DIR) == 0) { if (::FSFindFolder(kUserDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) { rv = NS_NewLocalFileWithFSRef(&fileRef, true, getter_AddRefs(macFile)); if (NS_SUCCEEDED(rv)) { localFile = macFile; } } } else if (nsCRT::strcmp(aProp, NS_MACOSX_LOCAL_PLUGIN_DIR) == 0) { if (::FSFindFolder(kLocalDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) { rv = NS_NewLocalFileWithFSRef(&fileRef, true, getter_AddRefs(macFile)); if (NS_SUCCEEDED(rv)) { localFile = macFile; } } } else if (nsCRT::strcmp(aProp, NS_MACOSX_JAVA2_PLUGIN_DIR) == 0) { static const char* const java2PluginDirPath = "/System/Library/Java/Support/Deploy.bundle/Contents/Resources/"; rv = NS_NewNativeLocalFile(nsDependentCString(java2PluginDirPath), true, getter_AddRefs(localFile)); } #else else if (nsCRT::strcmp(aProp, NS_ENV_PLUGINS_DIR) == 0) { NS_ERROR("Don't use nsAppFileLocationProvider::GetFile(NS_ENV_PLUGINS_DIR, ...). " "Use nsAppFileLocationProvider::GetFiles(...)."); const char* pathVar = PR_GetEnv("MOZ_PLUGIN_PATH"); if (pathVar && *pathVar) rv = NS_NewNativeLocalFile(nsDependentCString(pathVar), true, getter_AddRefs(localFile)); } else if (nsCRT::strcmp(aProp, NS_USER_PLUGINS_DIR) == 0) { #ifdef ENABLE_SYSTEM_EXTENSION_DIRS rv = GetProductDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) { rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME); } #else rv = NS_ERROR_FAILURE; #endif } #ifdef XP_UNIX else if (nsCRT::strcmp(aProp, NS_SYSTEM_PLUGINS_DIR) == 0) { #ifdef ENABLE_SYSTEM_EXTENSION_DIRS static const char* const sysLPlgDir = #if defined(HAVE_USR_LIB64_DIR) && defined(__LP64__) "/usr/lib64/mozilla/plugins"; #elif defined(__OpenBSD__) || defined (__FreeBSD__) "/usr/local/lib/mozilla/plugins"; #else "/usr/lib/mozilla/plugins"; #endif rv = NS_NewNativeLocalFile(nsDependentCString(sysLPlgDir), false, getter_AddRefs(localFile)); #else rv = NS_ERROR_FAILURE; #endif } #endif #endif else if (nsCRT::strcmp(aProp, NS_APP_SEARCH_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) { rv = localFile->AppendRelativeNativePath(SEARCH_DIR_NAME); } } else if (nsCRT::strcmp(aProp, NS_APP_USER_SEARCH_DIR) == 0) { rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, aResult); if (NS_SUCCEEDED(rv)) { rv = (*aResult)->AppendNative(SEARCH_DIR_NAME); } } else if (nsCRT::strcmp(aProp, NS_APP_INSTALL_CLEANUP_DIR) == 0) { // This is cloned so that embeddors will have a hook to override // with their own cleanup dir. See bugzilla bug #105087 rv = CloneMozBinDirectory(getter_AddRefs(localFile)); } if (localFile && NS_SUCCEEDED(rv)) { localFile.forget(aResult); return NS_OK; } return rv; }
/* * PKIX_PL_Initialize (see comments in pkix_pl_system.h) */ PKIX_Error * PKIX_PL_Initialize( PKIX_Boolean platformInitNeeded, PKIX_Boolean useArenas, void **pPlContext) { void *plContext = NULL; PKIX_ENTER(OBJECT, "PKIX_PL_Initialize"); /* * This function can only be called once. If it has already been * called, we return a positive status. */ if (pkix_pl_initialized) { PKIX_RETURN(OBJECT); } classTableLock = PR_NewLock(); if (classTableLock == NULL) { return PKIX_ALLOC_ERROR(); } if (PR_GetEnv("NSS_STRICT_SHUTDOWN")) { pkixLog = PR_NewLogModule("pkix"); } /* * Register Object, it is the base object of all other objects. */ pkix_pl_Object_RegisterSelf(plContext); /* * Register Error and String, since they will be needed if * there is a problem in registering any other type. */ pkix_Error_RegisterSelf(plContext); pkix_pl_String_RegisterSelf(plContext); /* * We register all other system types * (They don't need to be in order, but it's * easier to keep track of what types are registered * if we register them in the same order as their * numbers, defined in pkixt.h. */ pkix_pl_BigInt_RegisterSelf(plContext); /* 1-10 */ pkix_pl_ByteArray_RegisterSelf(plContext); pkix_pl_HashTable_RegisterSelf(plContext); pkix_List_RegisterSelf(plContext); pkix_Logger_RegisterSelf(plContext); pkix_pl_Mutex_RegisterSelf(plContext); pkix_pl_OID_RegisterSelf(plContext); pkix_pl_RWLock_RegisterSelf(plContext); pkix_pl_CertBasicConstraints_RegisterSelf(plContext); /* 11-20 */ pkix_pl_Cert_RegisterSelf(plContext); pkix_pl_CRL_RegisterSelf(plContext); pkix_pl_CRLEntry_RegisterSelf(plContext); pkix_pl_Date_RegisterSelf(plContext); pkix_pl_GeneralName_RegisterSelf(plContext); pkix_pl_CertNameConstraints_RegisterSelf(plContext); pkix_pl_PublicKey_RegisterSelf(plContext); pkix_TrustAnchor_RegisterSelf(plContext); pkix_pl_X500Name_RegisterSelf(plContext); /* 21-30 */ pkix_pl_HttpCertStoreContext_RegisterSelf(plContext); pkix_BuildResult_RegisterSelf(plContext); pkix_ProcessingParams_RegisterSelf(plContext); pkix_ValidateParams_RegisterSelf(plContext); pkix_ValidateResult_RegisterSelf(plContext); pkix_CertStore_RegisterSelf(plContext); pkix_CertChainChecker_RegisterSelf(plContext); pkix_RevocationChecker_RegisterSelf(plContext); pkix_CertSelector_RegisterSelf(plContext); pkix_ComCertSelParams_RegisterSelf(plContext); /* 31-40 */ pkix_CRLSelector_RegisterSelf(plContext); pkix_ComCRLSelParams_RegisterSelf(plContext); pkix_pl_CertPolicyInfo_RegisterSelf(plContext); pkix_pl_CertPolicyQualifier_RegisterSelf(plContext); pkix_pl_CertPolicyMap_RegisterSelf(plContext); pkix_PolicyNode_RegisterSelf(plContext); pkix_TargetCertCheckerState_RegisterSelf(plContext); pkix_BasicConstraintsCheckerState_RegisterSelf(plContext); pkix_PolicyCheckerState_RegisterSelf(plContext); pkix_pl_CollectionCertStoreContext_RegisterSelf(plContext); /* 41-50 */ pkix_CrlChecker_RegisterSelf(plContext); pkix_ForwardBuilderState_RegisterSelf(plContext); pkix_SignatureCheckerState_RegisterSelf(plContext); pkix_NameConstraintsCheckerState_RegisterSelf(plContext); pkix_pl_LdapRequest_RegisterSelf(plContext); pkix_pl_LdapResponse_RegisterSelf(plContext); pkix_pl_LdapDefaultClient_RegisterSelf(plContext); pkix_pl_Socket_RegisterSelf(plContext); pkix_ResourceLimits_RegisterSelf(plContext); /* 51-59 */ pkix_pl_MonitorLock_RegisterSelf(plContext); pkix_pl_InfoAccess_RegisterSelf(plContext); pkix_pl_AIAMgr_RegisterSelf(plContext); pkix_OcspChecker_RegisterSelf(plContext); pkix_pl_OcspCertID_RegisterSelf(plContext); pkix_pl_OcspRequest_RegisterSelf(plContext); pkix_pl_OcspResponse_RegisterSelf(plContext); pkix_pl_HttpDefaultClient_RegisterSelf(plContext); pkix_VerifyNode_RegisterSelf(plContext); pkix_EkuChecker_RegisterSelf(plContext); pkix_pl_CrlDp_RegisterSelf(plContext); if (pPlContext) { PKIX_CHECK(PKIX_PL_NssContext_Create (0, useArenas, NULL, &plContext), PKIX_NSSCONTEXTCREATEFAILED); *pPlContext = plContext; } pkix_pl_initialized = PKIX_TRUE; cleanup: PKIX_RETURN(OBJECT); }
nsresult StartupCache::Init() { // workaround for bug 653936 nsCOMPtr<nsIProtocolHandler> jarInitializer(do_GetService(NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "jar")); nsresult rv; mTable.Init(); #ifdef DEBUG mWriteObjectMap.Init(); #endif // This allows to override the startup cache filename // which is useful from xpcshell, when there is no ProfLDS directory to keep cache in. char *env = PR_GetEnv("MOZ_STARTUP_CACHE"); if (env) { rv = NS_NewLocalFile(NS_ConvertUTF8toUTF16(env), false, getter_AddRefs(mFile)); } else { nsCOMPtr<nsIFile> file; rv = NS_GetSpecialDirectory("ProfLDS", getter_AddRefs(file)); if (NS_FAILED(rv)) { // return silently, this will fail in mochitests's xpcshell process. return rv; } nsCOMPtr<nsIFile> profDir; NS_GetSpecialDirectory("ProfDS", getter_AddRefs(profDir)); if (profDir) { bool same; if (NS_SUCCEEDED(profDir->Equals(file, &same)) && !same) { // We no longer store the startup cache in the main profile // directory, so we should cleanup the old one. if (NS_SUCCEEDED( profDir->AppendNative(NS_LITERAL_CSTRING("startupCache")))) { profDir->Remove(true); } } } rv = file->AppendNative(NS_LITERAL_CSTRING("startupCache")); NS_ENSURE_SUCCESS(rv, rv); // Try to create the directory if it's not there yet rv = file->Create(nsIFile::DIRECTORY_TYPE, 0777); if (NS_FAILED(rv) && rv != NS_ERROR_FILE_ALREADY_EXISTS) return rv; rv = file->AppendNative(NS_LITERAL_CSTRING(sStartupCacheName)); NS_ENSURE_SUCCESS(rv, rv); mFile = do_QueryInterface(file); } NS_ENSURE_TRUE(mFile, NS_ERROR_UNEXPECTED); mObserverService = do_GetService("@mozilla.org/observer-service;1"); if (!mObserverService) { NS_WARNING("Could not get observerService."); return NS_ERROR_UNEXPECTED; } mListener = new StartupCacheListener(); rv = mObserverService->AddObserver(mListener, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false); NS_ENSURE_SUCCESS(rv, rv); rv = mObserverService->AddObserver(mListener, "startupcache-invalidate", false); NS_ENSURE_SUCCESS(rv, rv); rv = LoadArchive(RECORD_AGE); // Sometimes we don't have a cache yet, that's ok. // If it's corrupted, just remove it and start over. if (gIgnoreDiskCache || (NS_FAILED(rv) && rv != NS_ERROR_FILE_NOT_FOUND)) { NS_WARNING("Failed to load startupcache file correctly, removing!"); InvalidateCache(); } mMappingMemoryReporter = new NS_MEMORY_REPORTER_NAME(StartupCacheMapping); mDataMemoryReporter = new NS_MEMORY_REPORTER_NAME(StartupCacheData); (void)::NS_RegisterMemoryReporter(mMappingMemoryReporter); (void)::NS_RegisterMemoryReporter(mDataMemoryReporter); return NS_OK; }
NS_IMETHODIMP nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement, PRInt32 aPosition) { nsresult rv; nsCOMPtr<nsIImageLoadingContent> imageContent = do_QueryInterface(aElement, &rv); if (!imageContent) return rv; // get the image container nsCOMPtr<imgIRequest> request; rv = imageContent->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST, getter_AddRefs(request)); if (!request) return rv; nsCOMPtr<imgIContainer> container; rv = request->GetImage(getter_AddRefs(container)); if (!container) return rv; // Write the background file to the home directory. nsCAutoString filePath(PR_GetEnv("HOME")); // get the product brand name from localized strings nsString brandName; nsCID bundleCID = NS_STRINGBUNDLESERVICE_CID; nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(bundleCID)); if (bundleService) { nsCOMPtr<nsIStringBundle> brandBundle; rv = bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle)); if (NS_SUCCEEDED(rv) && brandBundle) { rv = brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(), getter_Copies(brandName)); NS_ENSURE_SUCCESS(rv, rv); } } // build the file name filePath.Append('/'); filePath.Append(NS_ConvertUTF16toUTF8(brandName)); filePath.Append("_wallpaper.png"); // write the image to a file in the home dir rv = WriteImage(filePath, container); // if the file was written successfully, set it as the system wallpaper nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID); if (gconf) { nsCAutoString options; if (aPosition == BACKGROUND_TILE) options.Assign("wallpaper"); else if (aPosition == BACKGROUND_STRETCH) options.Assign("stretched"); else options.Assign("centered"); gconf->SetString(NS_LITERAL_CSTRING(kDesktopOptionsKey), options); // Set the image to an empty string first to force a refresh // (since we could be writing a new image on top of an existing // Firefox_wallpaper.png and nautilus doesn't monitor the file for changes) gconf->SetString(NS_LITERAL_CSTRING(kDesktopImageKey), EmptyCString()); gconf->SetString(NS_LITERAL_CSTRING(kDesktopImageKey), filePath); gconf->SetBool(NS_LITERAL_CSTRING(kDesktopDrawBGKey), PR_TRUE); } return rv; }
// Read env vars at startup, so as to set sUnwindMode and sInterval. void read_profiler_env_vars() { bool nativeAvail = false; # if defined(HAVE_NATIVE_UNWIND) nativeAvail = true; # endif MOZ_ASSERT(sUnwindMode == UnwINVALID); MOZ_ASSERT(sUnwindInterval == 0); /* Set defaults */ sUnwindMode = nativeAvail ? UnwCOMBINED : UnwPSEUDO; sUnwindInterval = 0; /* We'll have to look elsewhere */ const char* strM = PR_GetEnv("MOZ_PROFILER_MODE"); const char* strI = PR_GetEnv("MOZ_PROFILER_INTERVAL"); const char* strF = PR_GetEnv("MOZ_PROFILER_STACK_SCAN"); if (strM) { if (0 == strcmp(strM, "pseudo")) sUnwindMode = UnwPSEUDO; else if (0 == strcmp(strM, "native") && nativeAvail) sUnwindMode = UnwNATIVE; else if (0 == strcmp(strM, "combined") && nativeAvail) sUnwindMode = UnwCOMBINED; else goto usage; } if (strI) { errno = 0; long int n = strtol(strI, (char**)NULL, 10); if (errno == 0 && n >= 1 && n <= 1000) { sUnwindInterval = n; } else goto usage; } if (strF) { errno = 0; long int n = strtol(strF, (char**)NULL, 10); if (errno == 0 && n >= 0 && n <= 100) { sUnwindStackScan = n; } else goto usage; } goto out; usage: LOG( "SPS: "); LOG( "SPS: Environment variable usage:"); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_MODE=native for native unwind only"); LOG( "SPS: MOZ_PROFILER_MODE=pseudo for pseudo unwind only"); LOG( "SPS: MOZ_PROFILER_MODE=combined for combined native & pseudo unwind"); LOG( "SPS: If unset, default is 'combined' on native-capable"); LOG( "SPS: platforms, 'pseudo' on others."); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_INTERVAL=<number> (milliseconds, 1 to 1000)"); LOG( "SPS: If unset, platform default is used."); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_VERBOSE"); LOG( "SPS: If set to any value, increases verbosity (recommended)."); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_STACK_SCAN=<number> (default is zero)"); LOG( "SPS: The number of dubious (stack-scanned) frames allowed"); LOG( "SPS: "); LOG( "SPS: MOZ_PROFILER_NEW"); LOG( "SPS: Needs to be set to use Breakpad-based unwinding."); LOG( "SPS: "); LOGF("SPS: This platform %s native unwinding.", nativeAvail ? "supports" : "does not support"); LOG( "SPS: "); /* Re-set defaults */ sUnwindMode = nativeAvail ? UnwCOMBINED : UnwPSEUDO; sUnwindInterval = 0; /* We'll have to look elsewhere */ sUnwindStackScan = 0; out: LOG( "SPS:"); LOGF("SPS: Unwind mode = %s", name_UnwMode(sUnwindMode)); LOGF("SPS: Sampling interval = %d ms (zero means \"platform default\")", (int)sUnwindInterval); LOGF("SPS: UnwindStackScan = %d (max dubious frames per unwind).", (int)sUnwindStackScan); LOG( "SPS: Use env var MOZ_PROFILER_MODE=help for further information."); LOG( "SPS:"); return; }
void mozilla_sampler_init(void* stackTop) { sInitCount++; if (stack_key_initialized) return; LOG("BEGIN mozilla_sampler_init"); if (!tlsPseudoStack.init() || !tlsTicker.init() || !tlsStackTop.init()) { LOG("Failed to init."); return; } stack_key_initialized = true; Sampler::Startup(); PseudoStack *stack = PseudoStack::create(); tlsPseudoStack.set(stack); bool isMainThread = true; Sampler::RegisterCurrentThread(isMainThread ? gGeckoThreadName : "Application Thread", stack, isMainThread, stackTop); // Read interval settings from MOZ_PROFILER_INTERVAL and stack-scan // threshhold from MOZ_PROFILER_STACK_SCAN. read_profiler_env_vars(); // platform specific initialization OS::Startup(); set_stderr_callback(mozilla_sampler_log); // We can't open pref so we use an environment variable // to know if we should trigger the profiler on startup // NOTE: Default const char *val = PR_GetEnv("MOZ_PROFILER_STARTUP"); if (!val || !*val) { return; } const char* features[] = {"js" , "leaf" , "threads" #if defined(XP_WIN) || defined(XP_MACOSX) \ || (defined(SPS_ARCH_arm) && defined(linux)) \ || defined(SPS_PLAT_amd64_linux) || defined(SPS_PLAT_x86_linux) , "stackwalk" #endif #if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK) , "java" #endif }; const char* threadFilters[] = { "GeckoMain", "Compositor" }; profiler_start(PROFILE_DEFAULT_ENTRY, PROFILE_DEFAULT_INTERVAL, features, MOZ_ARRAY_LENGTH(features), threadFilters, MOZ_ARRAY_LENGTH(threadFilters)); LOG("END mozilla_sampler_init"); }
void mozilla_sampler_init() { sInitCount++; if (stack_key_initialized) return; LOG("BEGIN mozilla_sampler_init"); if (!tlsPseudoStack.init() || !tlsTicker.init()) { LOG("Failed to init."); return; } stack_key_initialized = true; Sampler::Startup(); PseudoStack *stack = new PseudoStack(); tlsPseudoStack.set(stack); Sampler::RegisterCurrentThread("Gecko", stack, true); if (sps_version2()) { // Read mode settings from MOZ_PROFILER_MODE and interval // settings from MOZ_PROFILER_INTERVAL and stack-scan threshhold // from MOZ_PROFILER_STACK_SCAN. read_profiler_env_vars(); // Create the unwinder thread. ATM there is only one. uwt__init(); # if defined(SPS_PLAT_amd64_linux) || defined(SPS_PLAT_arm_android) \ || defined(SPS_PLAT_x86_linux) || defined(SPS_PLAT_x86_android) \ || defined(SPS_PLAT_x86_windows) || defined(SPS_PLAT_amd64_windows) /* no idea if windows is correct */ // On Linuxes, register this thread (temporarily) for profiling int aLocal; uwt__register_thread_for_profiling( &aLocal ); # elif defined(SPS_PLAT_amd64_darwin) || defined(SPS_PLAT_x86_darwin) // Registration is done in platform-macos.cc # else # error "Unknown plat" # endif } // Allow the profiler to be started using signals OS::RegisterStartHandler(); // We can't open pref so we use an environment variable // to know if we should trigger the profiler on startup // NOTE: Default const char *val = PR_GetEnv("MOZ_PROFILER_STARTUP"); if (!val || !*val) { return; } const char* features[] = {"js" , "leaf" #if defined(XP_WIN) || defined(XP_MACOSX) , "stackwalk" #endif }; profiler_start(PROFILE_DEFAULT_ENTRY, PROFILE_DEFAULT_INTERVAL, features, sizeof(features)/sizeof(const char*)); LOG("END mozilla_sampler_init"); }
Window XRemoteClient::FindBestWindow(const char *aProgram, const char *aUsername, const char *aProfile, bool aSupportsCommandLine) { Window root = RootWindowOfScreen(DefaultScreenOfDisplay(mDisplay)); Window bestWindow = 0; Window root2, parent, *kids; unsigned int nkids; // Get a list of the children of the root window, walk the list // looking for the best window that fits the criteria. if (!XQueryTree(mDisplay, root, &root2, &parent, &kids, &nkids)) { PR_LOG(sRemoteLm, PR_LOG_DEBUG, ("XQueryTree failed in XRemoteClient::FindBestWindow")); return 0; } if (!(kids && nkids)) { PR_LOG(sRemoteLm, PR_LOG_DEBUG, ("root window has no children")); return 0; } // We'll walk the list of windows looking for a window that best // fits the criteria here. for (unsigned int i = 0; i < nkids; i++) { Atom type; int format; unsigned long nitems, bytesafter; unsigned char *data_return = 0; Window w; w = kids[i]; // find the inner window with WM_STATE on it w = CheckWindow(w); int status = XGetWindowProperty(mDisplay, w, mMozVersionAtom, 0, (65536 / sizeof (long)), False, XA_STRING, &type, &format, &nitems, &bytesafter, &data_return); if (!data_return) continue; PRFloat64 version = PR_strtod((char*) data_return, nullptr); XFree(data_return); if (aSupportsCommandLine && !(version >= 5.1 && version < 6)) continue; data_return = 0; if (status != Success || type == None) continue; // If someone passed in a program name, check it against this one // unless it's "any" in which case, we don't care. If someone did // pass in a program name and this window doesn't support that // protocol, we don't include it in our list. if (aProgram && strcmp(aProgram, "any")) { status = XGetWindowProperty(mDisplay, w, mMozProgramAtom, 0, (65536 / sizeof(long)), False, XA_STRING, &type, &format, &nitems, &bytesafter, &data_return); // If the return name is not the same as what someone passed in, // we don't want this window. if (data_return) { if (strcmp(aProgram, (const char *)data_return)) { XFree(data_return); continue; } // This is actually the success condition. XFree(data_return); } else { // Doesn't support the protocol, even though the user // requested it. So we're not going to use this window. continue; } } // Check to see if it has the user atom on that window. If there // is then we need to make sure that it matches what we have. const char *username; if (aUsername) { username = aUsername; } else { username = PR_GetEnv("LOGNAME"); } if (username) { status = XGetWindowProperty(mDisplay, w, mMozUserAtom, 0, (65536 / sizeof(long)), False, XA_STRING, &type, &format, &nitems, &bytesafter, &data_return); // if there's a username compare it with what we have if (data_return) { // If the IDs aren't equal, we don't want this window. if (strcmp(username, (const char *)data_return)) { XFree(data_return); continue; } XFree(data_return); } } // Check to see if there's a profile name on this window. If // there is, then we need to make sure it matches what someone // passed in. if (aProfile) { status = XGetWindowProperty(mDisplay, w, mMozProfileAtom, 0, (65536 / sizeof(long)), False, XA_STRING, &type, &format, &nitems, &bytesafter, &data_return); // If there's a profile compare it with what we have if (data_return) { // If the profiles aren't equal, we don't want this window. if (strcmp(aProfile, (const char *)data_return)) { XFree(data_return); continue; } XFree(data_return); } } // Check to see if the window supports the new command-line passing // protocol, if that is requested. // If we got this far, this is the best window. It passed // all the tests. bestWindow = w; break; } if (kids) XFree((char *) kids); return bestWindow; }
/* * load a new module into our address space and initialize it. */ SECStatus secmod_LoadPKCS11Module(SECMODModule *mod, SECMODModule **oldModule) { PRLibrary *library = NULL; CK_C_GetFunctionList entry = NULL; CK_INFO info; CK_ULONG slotCount = 0; SECStatus rv; PRBool alreadyLoaded = PR_FALSE; char *disableUnload = NULL; if (mod->loaded) return SECSuccess; /* intenal modules get loaded from their internal list */ if (mod->internal && (mod->dllName == NULL)) { /* * Loads softoken as a dynamic library, * even though the rest of NSS assumes this as the "internal" module. */ if (!softokenLib && PR_SUCCESS != PR_CallOnce(&loadSoftokenOnce, &softoken_LoadDSO)) return SECFailure; PR_ATOMIC_INCREMENT(&softokenLoadCount); if (mod->isFIPS) { entry = (CK_C_GetFunctionList) PR_FindSymbol(softokenLib, "FC_GetFunctionList"); } else { entry = (CK_C_GetFunctionList) PR_FindSymbol(softokenLib, "NSC_GetFunctionList"); } if (!entry) return SECFailure; if (mod->isModuleDB) { mod->moduleDBFunc = (CK_C_GetFunctionList) PR_FindSymbol(softokenLib, "NSC_ModuleDBFunc"); } if (mod->moduleDBOnly) { mod->loaded = PR_TRUE; return SECSuccess; } } else { /* Not internal, load the DLL and look up C_GetFunctionList */ if (mod->dllName == NULL) { return SECFailure; } /* load the library. If this succeeds, then we have to remember to * unload the library if anything goes wrong from here on out... */ library = PR_LoadLibrary(mod->dllName); mod->library = (void *)library; if (library == NULL) { return SECFailure; } /* * now we need to get the entry point to find the function pointers */ if (!mod->moduleDBOnly) { entry = (CK_C_GetFunctionList) PR_FindSymbol(library, "C_GetFunctionList"); } if (mod->isModuleDB) { mod->moduleDBFunc = (void *) PR_FindSymbol(library, "NSS_ReturnModuleSpecData"); } if (mod->moduleDBFunc == NULL) mod->isModuleDB = PR_FALSE; if (entry == NULL) { if (mod->isModuleDB) { mod->loaded = PR_TRUE; mod->moduleDBOnly = PR_TRUE; return SECSuccess; } PR_UnloadLibrary(library); return SECFailure; } } /* * We need to get the function list */ if ((*entry)((CK_FUNCTION_LIST_PTR *)&mod->functionList) != CKR_OK) goto fail; #ifdef DEBUG_MODULE if (PR_TRUE) { modToDBG = PR_GetEnv("NSS_DEBUG_PKCS11_MODULE"); if (modToDBG && strcmp(mod->commonName, modToDBG) == 0) { mod->functionList = (void *)nss_InsertDeviceLog( (CK_FUNCTION_LIST_PTR)mod->functionList); } } #endif mod->isThreadSafe = PR_TRUE; /* Now we initialize the module */ rv = secmod_ModuleInit(mod, oldModule, &alreadyLoaded); if (rv != SECSuccess) { goto fail; } /* module has been reloaded, this module itself is done, * return to the caller */ if (mod->functionList == NULL) { mod->loaded = PR_TRUE; /* technically the module is loaded.. */ return SECSuccess; } /* check the version number */ if (PK11_GETTAB(mod)->C_GetInfo(&info) != CKR_OK) goto fail2; if (info.cryptokiVersion.major != 2) goto fail2; /* all 2.0 are a priori *not* thread safe */ if (info.cryptokiVersion.minor < 1) { if (!loadSingleThreadedModules) { PORT_SetError(SEC_ERROR_INCOMPATIBLE_PKCS11); goto fail2; } else { mod->isThreadSafe = PR_FALSE; } } mod->cryptokiVersion = info.cryptokiVersion; /* If we don't have a common name, get it from the PKCS 11 module */ if ((mod->commonName == NULL) || (mod->commonName[0] == 0)) { mod->commonName = PK11_MakeString(mod->arena,NULL, (char *)info.libraryDescription, sizeof(info.libraryDescription)); if (mod->commonName == NULL) goto fail2; } /* initialize the Slots */ if (PK11_GETTAB(mod)->C_GetSlotList(CK_FALSE, NULL, &slotCount) == CKR_OK) { CK_SLOT_ID *slotIDs; int i; CK_RV crv; mod->slots = (PK11SlotInfo **)PORT_ArenaAlloc(mod->arena, sizeof(PK11SlotInfo *) * slotCount); if (mod->slots == NULL) goto fail2; slotIDs = (CK_SLOT_ID *) PORT_Alloc(sizeof(CK_SLOT_ID)*slotCount); if (slotIDs == NULL) { goto fail2; } crv = PK11_GETTAB(mod)->C_GetSlotList(CK_FALSE, slotIDs, &slotCount); if (crv != CKR_OK) { PORT_Free(slotIDs); goto fail2; } /* Initialize each slot */ for (i=0; i < (int)slotCount; i++) { mod->slots[i] = PK11_NewSlotInfo(mod); PK11_InitSlot(mod,slotIDs[i],mod->slots[i]); /* look down the slot info table */ PK11_LoadSlotList(mod->slots[i],mod->slotInfo,mod->slotInfoCount); SECMOD_SetRootCerts(mod->slots[i],mod); /* explicitly mark the internal slot as such if IsInternalKeySlot() * is set */ if (secmod_IsInternalKeySlot(mod) && (i == (mod->isFIPS ? 0 : 1))) { pk11_SetInternalKeySlotIfFirst(mod->slots[i]); } } mod->slotCount = slotCount; mod->slotInfoCount = 0; PORT_Free(slotIDs); } mod->loaded = PR_TRUE; mod->moduleID = nextModuleID++; return SECSuccess; fail2: if (enforceAlreadyInitializedError || (!alreadyLoaded)) { PK11_GETTAB(mod)->C_Finalize(NULL); } fail: mod->functionList = NULL; disableUnload = PR_GetEnv("NSS_DISABLE_UNLOAD"); if (library && !disableUnload) { PR_UnloadLibrary(library); } return SECFailure; }
int main(int argc, char* argv[]) { if (argc > 1 && (IsArg(argv[1], "h") || IsArg(argv[1], "help") || IsArg(argv[1], "?"))) { Usage(argv[0]); return 0; } if (argc == 2 && (IsArg(argv[1], "v") || IsArg(argv[1], "version"))) { nsCAutoString milestone; nsCAutoString version; GetGREVersion(argv[0], &milestone, &version); Output(PR_FALSE, "Mozilla XULRunner %s - %s\n", milestone.get(), version.get()); return 0; } if (argc > 1) { nsCAutoString milestone; nsresult rv = GetGREVersion(argv[0], &milestone, nsnull); if (NS_FAILED(rv)) return 2; if (IsArg(argv[1], "gre-version")) { if (argc != 2) { Usage(argv[0]); return 1; } printf("%s\n", milestone.get()); return 0; } if (IsArg(argv[1], "install-app")) { if (argc < 3 || argc > 5) { Usage(argv[0]); return 1; } char *appLocation = argv[2]; char *installTo = nsnull; if (argc > 3) { installTo = argv[3]; if (!*installTo) // left blank? installTo = nsnull; } char *leafName = nsnull; if (argc > 4) { leafName = argv[4]; if (!*leafName) leafName = nsnull; } nsCOMPtr<nsIFile> regDir; rv = GetXULRunnerDir(argv[0], getter_AddRefs(regDir)); if (NS_FAILED(rv)) return 2; return InstallXULApp(regDir, appLocation, installTo, leafName); } } const char *appDataFile = PR_GetEnv("XUL_APP_FILE"); if (!(appDataFile && *appDataFile)) { if (argc < 2) { Usage(argv[0]); return 1; } if (IsArg(argv[1], "app")) { if (argc == 2) { Usage(argv[0]); return 1; } argv[1] = argv[0]; ++argv; --argc; } appDataFile = argv[1]; argv[1] = argv[0]; ++argv; --argc; static char kAppEnv[MAXPATHLEN]; PR_snprintf(kAppEnv, MAXPATHLEN, "XUL_APP_FILE=%s", appDataFile); PR_SetEnv(kAppEnv); } nsCOMPtr<nsILocalFile> appDataLF; nsresult rv = XRE_GetFileFromPath(appDataFile, getter_AddRefs(appDataLF)); if (NS_FAILED(rv)) { Output(PR_TRUE, "Error: unrecognized application.ini path.\n"); return 2; } AutoAppData appData(appDataLF); if (!appData) { Output(PR_TRUE, "Error: couldn't parse application.ini.\n"); return 2; } return XRE_main(argc, argv, appData); }
NS_IMETHODIMP nsAppFileLocationProvider::GetFile(const char *prop, PRBool *persistent, nsIFile **_retval) { nsCOMPtr<nsILocalFile> localFile; nsresult rv = NS_ERROR_FAILURE; NS_ENSURE_ARG(prop); *_retval = nsnull; *persistent = PR_TRUE; #ifdef XP_MACOSX FSRef fileRef; nsCOMPtr<nsILocalFileMac> macFile; #endif if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_DIR) == 0) { rv = GetProductDirectory(getter_AddRefs(localFile)); } else if (nsCRT::strcmp(prop, NS_APP_APPLICATION_REGISTRY_FILE) == 0) { rv = GetProductDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) rv = localFile->AppendNative(APP_REGISTRY_NAME); } else if (nsCRT::strcmp(prop, NS_APP_DEFAULTS_50_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME); } else if (nsCRT::strcmp(prop, NS_APP_PREF_DEFAULTS_50_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) { rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME); if (NS_SUCCEEDED(rv)) rv = localFile->AppendRelativeNativePath(DEFAULTS_PREF_DIR_NAME); } } else if (nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_50_DIR) == 0 || nsCRT::strcmp(prop, NS_APP_PROFILE_DEFAULTS_NLOC_50_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) { rv = localFile->AppendRelativeNativePath(DEFAULTS_DIR_NAME); if (NS_SUCCEEDED(rv)) rv = localFile->AppendRelativeNativePath(DEFAULTS_PROFILE_DIR_NAME); } } else if (nsCRT::strcmp(prop, NS_APP_USER_PROFILES_ROOT_DIR) == 0) { rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile)); } else if (nsCRT::strcmp(prop, NS_APP_USER_PROFILES_LOCAL_ROOT_DIR) == 0) { rv = GetDefaultUserProfileRoot(getter_AddRefs(localFile), PR_TRUE); } else if (nsCRT::strcmp(prop, NS_APP_RES_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) rv = localFile->AppendRelativeNativePath(RES_DIR_NAME); } else if (nsCRT::strcmp(prop, NS_APP_CHROME_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) rv = localFile->AppendRelativeNativePath(CHROME_DIR_NAME); } else if (nsCRT::strcmp(prop, NS_APP_PLUGINS_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME); } #ifdef XP_MACOSX else if (nsCRT::strcmp(prop, NS_MACOSX_USER_PLUGIN_DIR) == 0) { if (::FSFindFolder(kUserDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) { rv = NS_NewLocalFileWithFSRef(&fileRef, PR_TRUE, getter_AddRefs(macFile)); if (NS_SUCCEEDED(rv)) localFile = macFile; } } else if (nsCRT::strcmp(prop, NS_MACOSX_LOCAL_PLUGIN_DIR) == 0) { if (::FSFindFolder(kLocalDomain, kInternetPlugInFolderType, false, &fileRef) == noErr) { rv = NS_NewLocalFileWithFSRef(&fileRef, PR_TRUE, getter_AddRefs(macFile)); if (NS_SUCCEEDED(rv)) localFile = macFile; } } else if (nsCRT::strcmp(prop, NS_MACOSX_JAVA2_PLUGIN_DIR) == 0) { static const char *const java2PluginDirPath = "/System/Library/Frameworks/JavaVM.framework/Versions/Current/Resources/"; NS_NewNativeLocalFile(nsDependentCString(java2PluginDirPath), PR_TRUE, getter_AddRefs(localFile)); } #else else if (nsCRT::strcmp(prop, NS_ENV_PLUGINS_DIR) == 0) { NS_ERROR("Don't use nsAppFileLocationProvider::GetFile(NS_ENV_PLUGINS_DIR, ...). " "Use nsAppFileLocationProvider::GetFiles(...)."); const char *pathVar = PR_GetEnv("MOZ_PLUGIN_PATH"); if (pathVar && *pathVar) rv = NS_NewNativeLocalFile(nsDependentCString(pathVar), PR_TRUE, getter_AddRefs(localFile)); } else if (nsCRT::strcmp(prop, NS_USER_PLUGINS_DIR) == 0) { rv = GetProductDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) rv = localFile->AppendRelativeNativePath(PLUGINS_DIR_NAME); } #ifdef XP_UNIX else if (nsCRT::strcmp(prop, NS_SYSTEM_PLUGINS_DIR) == 0) { static const char *const sysLPlgDir = #if defined(HAVE_USR_LIB64_DIR) && defined(__LP64__) "/usr/lib64/mozilla/plugins"; #else "/usr/lib/mozilla/plugins"; #endif rv = NS_NewNativeLocalFile(nsDependentCString(sysLPlgDir), PR_FALSE, getter_AddRefs(localFile)); } #endif #endif else if (nsCRT::strcmp(prop, NS_APP_SEARCH_DIR) == 0) { rv = CloneMozBinDirectory(getter_AddRefs(localFile)); if (NS_SUCCEEDED(rv)) rv = localFile->AppendRelativeNativePath(SEARCH_DIR_NAME); } else if (nsCRT::strcmp(prop, NS_APP_USER_SEARCH_DIR) == 0) { rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, _retval); if (NS_SUCCEEDED(rv)) rv = (*_retval)->AppendNative(SEARCH_DIR_NAME); } else if (nsCRT::strcmp(prop, NS_APP_INSTALL_CLEANUP_DIR) == 0) { // This is cloned so that embeddors will have a hook to override // with their own cleanup dir. See bugzilla bug #105087 rv = CloneMozBinDirectory(getter_AddRefs(localFile)); } if (localFile && NS_SUCCEEDED(rv)) return localFile->QueryInterface(NS_GET_IID(nsIFile), (void**)_retval); return rv; }
NS_IMETHODIMP nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement, int32_t aPosition) { nsCString brandName; nsresult rv = GetBrandName(brandName); NS_ENSURE_SUCCESS(rv, rv); // build the file name nsCString filePath(PR_GetEnv("HOME")); filePath.Append('/'); filePath.Append(brandName); filePath.AppendLiteral("_wallpaper.png"); // get the image container nsCOMPtr<nsIImageLoadingContent> imageContent(do_QueryInterface(aElement, &rv)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<imgIRequest> request; rv = imageContent->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST, getter_AddRefs(request)); NS_ENSURE_TRUE(request, rv); nsCOMPtr<imgIContainer> container; rv = request->GetImage(getter_AddRefs(container)); NS_ENSURE_TRUE(request, rv); nsCOMPtr<nsIImageToPixbuf> imgToPixbuf(do_GetService("@mozilla.org/widget/image-to-gdk-pixbuf;1")); if (!imgToPixbuf) return NS_ERROR_NOT_AVAILABLE; GdkPixbuf* pixbuf = imgToPixbuf->ConvertImageToPixbuf(container); if (!pixbuf) return NS_ERROR_NOT_AVAILABLE; // write the image to a file in the home dir gboolean res = gdk_pixbuf_save(pixbuf, filePath.get(), "png", nullptr, nullptr); g_object_unref(pixbuf); if (!res) return NS_ERROR_FAILURE; // set desktop wallpaper filling style const char* options; switch (aPosition) { case BACKGROUND_TILE: options = "wallpaper"; break; case BACKGROUND_STRETCH: options = "stretched"; break; case BACKGROUND_FILL: options = "zoom"; break; case BACKGROUND_FIT: options = "scaled"; break; default: options = "centered"; break; } // Try GSettings first. If we don't have GSettings or the right schema, fall back // to using GConf instead. Note that if GSettings works ok, the changes get // mirrored to GConf by the gsettings->gconf bridge in gnome-settings-daemon nsCOMPtr<nsIGSettingsService> gsettings(do_GetService(NS_GSETTINGSSERVICE_CONTRACTID)); if (gsettings) { nsCOMPtr<nsIGSettingsCollection> background_settings; gsettings->GetCollectionForSchema(NS_LITERAL_CSTRING(OGDB_SCHEMA), getter_AddRefs(background_settings)); if (background_settings) { gchar *file_uri = g_filename_to_uri(filePath.get(), nullptr, nullptr); if (!file_uri) return NS_ERROR_FAILURE; background_settings->SetString(NS_LITERAL_CSTRING(OGDB_OPTIONS), nsDependentCString(options)); background_settings->SetString(NS_LITERAL_CSTRING(OGDB_IMAGE), nsDependentCString(file_uri)); g_free(file_uri); background_settings->SetBoolean(NS_LITERAL_CSTRING(OGDB_DRAWBG), true); return NS_OK; } } // if the file was written successfully, set it as the system wallpaper nsCOMPtr<nsIGConfService> gconf(do_GetService(NS_GCONFSERVICE_CONTRACTID)); if (gconf) { gconf->SetString(NS_LITERAL_CSTRING(DGB_OPTIONS), nsDependentCString(options)); // Set the image to an empty string first to force a refresh (since we could // be writing a new image on top of an existing SeaMonkey_wallpaper.png // and nautilus doesn't monitor the file for changes). gconf->SetString(NS_LITERAL_CSTRING(DGB_IMAGE), EmptyCString()); gconf->SetString(NS_LITERAL_CSTRING(DGB_IMAGE), filePath); gconf->SetBool(NS_LITERAL_CSTRING(DGB_DRAWBG), true); } return NS_OK; }
//---------------------------------------------------------------------------------------- // GetProductDirectory - Gets the directory which contains the application data folder // // UNIX : ~/.mozilla/ // WIN : <Application Data folder on user's machine>\Mozilla // Mac : :Documents:Mozilla: //---------------------------------------------------------------------------------------- NS_METHOD nsAppFileLocationProvider::GetProductDirectory(nsILocalFile **aLocalFile, PRBool aLocal) { NS_ENSURE_ARG_POINTER(aLocalFile); nsresult rv; PRBool exists; nsCOMPtr<nsILocalFile> localDir; #if defined(XP_MACOSX) FSRef fsRef; OSType folderType = aLocal ? kCachedDataFolderType : kDomainLibraryFolderType; OSErr err = ::FSFindFolder(kUserDomain, folderType, kCreateFolder, &fsRef); if (err) return NS_ERROR_FAILURE; NS_NewLocalFile(EmptyString(), PR_TRUE, getter_AddRefs(localDir)); if (!localDir) return NS_ERROR_FAILURE; nsCOMPtr<nsILocalFileMac> localDirMac(do_QueryInterface(localDir)); rv = localDirMac->InitWithFSRef(&fsRef); if (NS_FAILED(rv)) return rv; #elif defined(XP_OS2) nsCOMPtr<nsIProperties> directoryService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; rv = directoryService->Get(NS_OS2_HOME_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir)); if (NS_FAILED(rv)) return rv; #elif defined(XP_WIN) nsCOMPtr<nsIProperties> directoryService = do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; const char* prop = aLocal ? NS_WIN_LOCAL_APPDATA_DIR : NS_WIN_APPDATA_DIR; rv = directoryService->Get(prop, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir)); if (NS_SUCCEEDED(rv)) rv = localDir->Exists(&exists); if (NS_FAILED(rv) || !exists) { // On some Win95 machines, NS_WIN_APPDATA_DIR does not exist - revert to NS_WIN_WINDOWS_DIR localDir = nsnull; rv = directoryService->Get(NS_WIN_WINDOWS_DIR, NS_GET_IID(nsILocalFile), getter_AddRefs(localDir)); } if (NS_FAILED(rv)) return rv; #elif defined(XP_UNIX) rv = NS_NewNativeLocalFile(nsDependentCString(PR_GetEnv("HOME")), PR_TRUE, getter_AddRefs(localDir)); if (NS_FAILED(rv)) return rv; #elif defined(XP_BEOS) char path[MAXPATHLEN]; find_directory(B_USER_SETTINGS_DIRECTORY, 0, 0, path, MAXPATHLEN); // Need enough space to add the trailing backslash int len = strlen(path); if (len > MAXPATHLEN-2) return NS_ERROR_FAILURE; path[len] = '/'; path[len+1] = '\0'; rv = NS_NewNativeLocalFile(nsDependentCString(path), PR_TRUE, getter_AddRefs(localDir)); if (NS_FAILED(rv)) return rv; #else #error dont_know_how_to_get_product_dir_on_your_platform #endif rv = localDir->AppendRelativeNativePath(DEFAULT_PRODUCT_DIR); if (NS_FAILED(rv)) return rv; rv = localDir->Exists(&exists); if (NS_SUCCEEDED(rv) && !exists) rv = localDir->Create(nsIFile::DIRECTORY_TYPE, 0700); if (NS_FAILED(rv)) return rv; *aLocalFile = localDir; NS_ADDREF(*aLocalFile); return rv; }
/** * Peforms intialization of the MANDATORY components of the Video Engine */ MediaConduitErrorCode WebrtcVideoConduit::Init() { CSFLogDebug(logTag, "%s ", __FUNCTION__); if( !(mVideoEngine = webrtc::VideoEngine::Create()) ) { CSFLogError(logTag, "%s Unable to create video engine ", __FUNCTION__); return kMediaConduitSessionNotInited; } PRLogModuleInfo *logs = GetWebRTCLogInfo(); if (!gWebrtcTraceLoggingOn && logs && logs->level > 0) { // no need to a critical section or lock here gWebrtcTraceLoggingOn = 1; const char *file = PR_GetEnv("WEBRTC_TRACE_FILE"); if (!file) { file = "WebRTC.log"; } CSFLogDebug(logTag, "%s Logging webrtc to %s level %d", __FUNCTION__, file, logs->level); mVideoEngine->SetTraceFilter(logs->level); mVideoEngine->SetTraceFile(file); } if( !(mPtrViEBase = ViEBase::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video base interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrViECapture = ViECapture::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video capture interface", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrViECodec = ViECodec::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video codec interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrViENetwork = ViENetwork::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video network interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrViERender = ViERender::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video render interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } if( !(mPtrRTP = webrtc::ViERTP_RTCP::GetInterface(mVideoEngine))) { CSFLogError(logTag, "%s Unable to get video RTCP interface ", __FUNCTION__); return kMediaConduitSessionNotInited; } CSFLogDebug(logTag, "%s Engine Created: Init'ng the interfaces ",__FUNCTION__); if(mPtrViEBase->Init() == -1) { CSFLogError(logTag, " %s Video Engine Init Failed %d ",__FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitSessionNotInited; } if(mPtrViEBase->CreateChannel(mChannel) == -1) { CSFLogError(logTag, " %s Channel creation Failed %d ",__FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitChannelError; } if(mPtrViENetwork->RegisterSendTransport(mChannel, *this) == -1) { CSFLogError(logTag, "%s ViENetwork Failed %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitTransportRegistrationFail; } mPtrExtCapture = 0; if(mPtrViECapture->AllocateExternalCaptureDevice(mCapId, mPtrExtCapture) == -1) { CSFLogError(logTag, "%s Unable to Allocate capture module: %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitCaptureError; } if(mPtrViECapture->ConnectCaptureDevice(mCapId,mChannel) == -1) { CSFLogError(logTag, "%s Unable to Connect capture module: %d ", __FUNCTION__,mPtrViEBase->LastError()); return kMediaConduitCaptureError; } if(mPtrViERender->AddRenderer(mChannel, webrtc::kVideoI420, (webrtc::ExternalRenderer*) this) == -1) { CSFLogError(logTag, "%s Failed to added external renderer ", __FUNCTION__); return kMediaConduitInvalidRenderer; } // Set up some parameters, per juberti. Set MTU. if(mPtrViENetwork->SetMTU(mChannel, 1200) != 0) { CSFLogError(logTag, "%s MTU Failed %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitMTUError; } // Turn on RTCP and loss feedback reporting. if(mPtrRTP->SetRTCPStatus(mChannel, webrtc::kRtcpCompound_RFC4585) != 0) { CSFLogError(logTag, "%s RTCPStatus Failed %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitRTCPStatusError; } // Enable pli as key frame request method. if(mPtrRTP->SetKeyFrameRequestMethod(mChannel, webrtc::kViEKeyFrameRequestPliRtcp) != 0) { CSFLogError(logTag, "%s KeyFrameRequest Failed %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitKeyFrameRequestError; } // Enable lossless transport if (mPtrRTP->SetNACKStatus(mChannel, true) != 0) { CSFLogError(logTag, "%s NACKStatus Failed %d ", __FUNCTION__, mPtrViEBase->LastError()); return kMediaConduitNACKStatusError; } CSFLogError(logTag, "%s Initialization Done", __FUNCTION__); return kMediaConduitNoError; }
static int X11Error(Display *display, XErrorEvent *event) { // Get an indication of how long ago the request that caused the error was // made. unsigned long age = NextRequest(display) - event->serial; // Get a string to represent the request that caused the error. nsCAutoString message; if (event->request_code < 128) { // Core protocol request message.AppendInt(event->request_code); } else { // Extension request // man XSetErrorHandler says "the error handler should not call any // functions (directly or indirectly) on the display that will generate // protocol requests or that will look for input events" so we use another // temporary Display to request extension information. This assumes on // the DISPLAY environment variable has been set and matches what was used // to open |display|. Display *tmpDisplay = XOpenDisplay(NULL); if (tmpDisplay) { int nExts; char** extNames = XListExtensions(tmpDisplay, &nExts); int first_error; if (extNames) { for (int i = 0; i < nExts; ++i) { int major_opcode, first_event; if (XQueryExtension(tmpDisplay, extNames[i], &major_opcode, &first_event, &first_error) && major_opcode == event->request_code) { message.Append(extNames[i]); message.Append('.'); message.AppendInt(event->minor_code); break; } } XFreeExtensionList(extNames); } XCloseDisplay(tmpDisplay); #ifdef MOZ_WIDGET_GTK2 // GDK2 calls XCloseDevice the devices that it opened on startup, but // the XI protocol no longer ensures that the devices will still exist. // If they have been removed, then a BadDevice error results. Ignore // this error. if (message.EqualsLiteral("XInputExtension.4") && event->error_code == first_error + 0) { return 0; } #endif } } char buffer[BUFSIZE]; if (message.IsEmpty()) { buffer[0] = '\0'; } else { XGetErrorDatabaseText(display, "XRequest", message.get(), "", buffer, sizeof(buffer)); } nsCAutoString notes; if (buffer[0]) { notes.Append(buffer); } else { notes.Append("Request "); notes.AppendInt(event->request_code); notes.Append('.'); notes.AppendInt(event->minor_code); } notes.Append(": "); // Get a string to describe the error. XGetErrorText(display, event->error_code, buffer, sizeof(buffer)); notes.Append(buffer); // For requests where Xlib gets the reply synchronously, |age| will be 1 // and the stack will include the function making the request. For // asynchronous requests, the current stack will often be unrelated to the // point of making the request, even if |age| is 1, but sometimes this may // help us count back to the point of the request. With XSynchronize on, // the stack will include the function making the request, even though // |age| will be 2 for asynchronous requests because XSynchronize is // implemented by an empty request from an XSync, which has not yet been // processed. if (age > 1) { // XSynchronize returns the previous "after function". If a second // XSynchronize call returns the same function after an enable call then // synchronization must have already been enabled. if (XSynchronize(display, True) == XSynchronize(display, False)) { notes.Append("; sync"); } else { notes.Append("; "); notes.AppendInt(PRUint32(age)); notes.Append(" requests ago"); } } #ifdef MOZ_CRASHREPORTER switch (XRE_GetProcessType()) { case GeckoProcessType_Default: case GeckoProcessType_Plugin: case GeckoProcessType_Content: CrashReporter::AppendAppNotesToCrashReport(notes); break; default: ; // crash report notes not supported. } #endif #ifdef DEBUG // The resource id is unlikely to be useful in a crash report without // context of other ids, but add it to the debug console output. notes.Append("; id=0x"); notes.AppendInt(PRUint32(event->resourceid), 16); #ifdef MOZ_X11 // Actually, for requests where Xlib gets the reply synchronously, // MOZ_X_SYNC=1 will not be necessary, but we don't have a table to tell us // which requests get a synchronous reply. if (!PR_GetEnv("MOZ_X_SYNC")) { notes.Append("\nRe-running with MOZ_X_SYNC=1 in the environment may give a more helpful backtrace."); } #endif #endif #ifdef MOZ_WIDGET_QT // We should not abort here if MOZ_X_SYNC is not set // until http://bugreports.qt.nokia.com/browse/QTBUG-4042 // not fixed, just print error value if (!PR_GetEnv("MOZ_X_SYNC")) { fprintf(stderr, "XError: %s\n", notes.get()); return 0; // temporary workaround for bug 161472 } #endif NS_RUNTIMEABORT(notes.get()); return 0; // not reached }