bool pni_init_client(pn_transport_t* transport) { pni_sasl_t *sasl = transport->sasl; int result; sasl_conn_t *cyrus_conn = NULL; do { if (sasl->config_dir) { result = sasl_set_path(SASL_PATH_TYPE_CONFIG, sasl->config_dir); if (result!=SASL_OK) break; } result = sasl_client_init(NULL); if (result!=SASL_OK) break; const sasl_callback_t *callbacks = sasl->username ? sasl->password ? pni_user_password_callbacks : pni_user_callbacks : NULL; result = sasl_client_new(amqp_service, sasl->remote_fqdn, NULL, NULL, callbacks, 0, &cyrus_conn); if (result!=SASL_OK) break; sasl->impl_context = cyrus_conn; sasl_security_properties_t secprops = {0}; secprops.security_flags = ( sasl->allow_insecure_mechs ? 0 : SASL_SEC_NOPLAINTEXT ) | ( transport->auth_required ? SASL_SEC_NOANONYMOUS : 0 ) ; secprops.min_ssf = 0; secprops.max_ssf = 2048; secprops.maxbufsize = PN_SASL_MAX_BUFFSIZE; result = sasl_setprop(cyrus_conn, SASL_SEC_PROPS, &secprops); if (result!=SASL_OK) break; sasl_ssf_t ssf = sasl->external_ssf; result = sasl_setprop(cyrus_conn, SASL_SSF_EXTERNAL, &ssf); if (result!=SASL_OK) break; const char *extid = sasl->external_auth; if (extid) { result = sasl_setprop(cyrus_conn, SASL_AUTH_EXTERNAL, extid); } } while (false); cyrus_conn = (sasl_conn_t*) sasl->impl_context; return pni_check_sasl_result(cyrus_conn, result, transport); }
XSASL_CLIENT_IMPL *xsasl_cyrus_client_init(const char *unused_client_type, const char *unused_path_info) { XSASL_CLIENT_IMPL *xp; int sasl_status; /* * Global callbacks. These have no per-session context. */ static sasl_callback_t callbacks[] = { {SASL_CB_LOG, (XSASL_CYRUS_CB) &xsasl_cyrus_log, 0}, {SASL_CB_LIST_END, 0, 0} }; #if SASL_VERSION_MAJOR >= 2 && (SASL_VERSION_MINOR >= 2 \ || (SASL_VERSION_MINOR == 1 && SASL_VERSION_STEP >= 19)) int sasl_major; int sasl_minor; int sasl_step; /* * DLL hell guard. */ sasl_version_info((const char **) 0, (const char **) 0, &sasl_major, &sasl_minor, &sasl_step, (int *) 0); if (sasl_major != SASL_VERSION_MAJOR #if 0 || sasl_minor != SASL_VERSION_MINOR || sasl_step != SASL_VERSION_STEP #endif ) { msg_warn("incorrect SASL library version. " "Postfix was built with include files from version %d.%d.%d, " "but the run-time library version is %d.%d.%d", SASL_VERSION_MAJOR, SASL_VERSION_MINOR, SASL_VERSION_STEP, sasl_major, sasl_minor, sasl_step); return (0); } #endif if (*var_cyrus_conf_path) { #ifdef SASL_PATH_TYPE_CONFIG /* Cyrus SASL 2.1.22 */ if (sasl_set_path(SASL_PATH_TYPE_CONFIG, var_cyrus_conf_path) != SASL_OK) msg_warn("failed to set Cyrus SASL configuration path: \"%s\"", var_cyrus_conf_path); #else msg_warn("%s is not empty, but setting the Cyrus SASL configuration " "path is not supported with SASL library version %d.%d.%d", VAR_CYRUS_CONF_PATH, SASL_VERSION_MAJOR, SASL_VERSION_MINOR, SASL_VERSION_STEP); #endif } /* * Initialize the SASL library. */ if ((sasl_status = sasl_client_init(callbacks)) != SASL_OK) { msg_warn("SASL library initialization error: %s", xsasl_cyrus_strerror(sasl_status)); return (0); } /* * Return a generic XSASL_CLIENT_IMPL object. We don't need to extend it * with our own methods or data. */ xp = (XSASL_CLIENT_IMPL *) mymalloc(sizeof(*xp)); xp->create = xsasl_cyrus_client_create; xp->done = xsasl_cyrus_client_done; return (xp); }
static void init_plugin(PurplePlugin *plugin) { #ifdef HAVE_CYRUS_SASL #ifdef _WIN32 UINT old_error_mode; gchar *sasldir; #endif int ret; #endif PurpleAccountUserSplit *split; PurpleAccountOption *option; /* Translators: 'domain' is used here in the context of Internet domains, e.g. pidgin.im */ split = purple_account_user_split_new(_("Domain"), NULL, '@'); purple_account_user_split_set_reverse(split, FALSE); prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); split = purple_account_user_split_new(_("Resource"), NULL, '/'); purple_account_user_split_set_reverse(split, FALSE); prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); option = purple_account_option_bool_new(_("Require SSL/TLS"), "require_tls", FALSE); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); option = purple_account_option_bool_new(_("Force old (port 5223) SSL"), "old_ssl", FALSE); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); option = purple_account_option_bool_new( _("Allow plaintext auth over unencrypted streams"), "auth_plain_in_clear", FALSE); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); option = purple_account_option_int_new(_("Connect port"), "port", 5222); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); option = purple_account_option_string_new(_("Connect server"), "connect_server", NULL); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); option = purple_account_option_string_new(_("File transfer proxies"), "ft_proxies", /* TODO: Is this an acceptable default? */ "proxy.jabber.org"); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); /* this should probably be part of global smiley theme settings later on, shared with MSN */ option = purple_account_option_bool_new(_("Show Custom Smileys"), "custom_smileys", TRUE); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); jabber_init_plugin(plugin); purple_prefs_remove("/plugins/prpl/jabber"); /* XXX - If any other plugin wants SASL this won't be good ... */ #ifdef HAVE_CYRUS_SASL #ifdef _WIN32 sasldir = g_build_filename(wpurple_install_dir(), "sasl2", NULL); sasl_set_path(SASL_PATH_TYPE_PLUGIN, sasldir); g_free(sasldir); /* Suppress error popups for failing to load sasl plugins */ old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS); #endif if ((ret = sasl_client_init(NULL)) != SASL_OK) { purple_debug_error("xmpp", "Error (%d) initializing SASL.\n", ret); } #ifdef _WIN32 /* Restore the original error mode */ SetErrorMode(old_error_mode); #endif #endif jabber_register_commands(); jabber_iq_init(); jabber_pep_init(); jabber_tune_init(); jabber_caps_init(); jabber_data_init(); jabber_add_feature("avatarmeta", AVATARNAMESPACEMETA, jabber_pep_namespace_only_when_pep_enabled_cb); jabber_add_feature("avatardata", AVATARNAMESPACEDATA, jabber_pep_namespace_only_when_pep_enabled_cb); jabber_add_feature("buzz", "http://www.xmpp.org/extensions/xep-0224.html#ns", jabber_buzz_isenabled); jabber_add_feature("bob", XEP_0231_NAMESPACE, jabber_custom_smileys_isenabled); jabber_pep_register_handler("avatar", AVATARNAMESPACEMETA, jabber_buddy_avatar_update_metadata); }
static void init_plugin(PurplePlugin *plugin) { #ifdef HAVE_CYRUS_SASL #ifdef _WIN32 UINT old_error_mode; gchar *sasldir; #endif int ret; #endif PurpleAccountUserSplit *split; PurpleAccountOption *option; /* Translators: 'domain' is used here in the context of Internet domains, e.g. pidgin.im */ split = purple_account_user_split_new(_("Domain"), NULL, '@'); purple_account_user_split_set_reverse(split, FALSE); prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); split = purple_account_user_split_new(_("Resource"), NULL, '/'); purple_account_user_split_set_reverse(split, FALSE); prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); option = purple_account_option_bool_new(_("Require SSL/TLS"), "require_tls", JABBER_DEFAULT_REQUIRE_TLS); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); option = purple_account_option_bool_new(_("Force old (port 5223) SSL"), "old_ssl", FALSE); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); option = purple_account_option_bool_new( _("Allow plaintext auth over unencrypted streams"), "auth_plain_in_clear", FALSE); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); option = purple_account_option_int_new(_("Connect port"), "port", 5222); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); option = purple_account_option_string_new(_("Connect server"), "connect_server", NULL); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); option = purple_account_option_string_new(_("File transfer proxies"), "ft_proxies", /* TODO: Is this an acceptable default? * Also, keep this in sync as they add more servers */ "proxy.eu.jabber.org"); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); option = purple_account_option_string_new(_("BOSH URL"), "bosh_url", NULL); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); /* this should probably be part of global smiley theme settings later on, shared with MSN */ option = purple_account_option_bool_new(_("Show Custom Smileys"), "custom_smileys", TRUE); prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); my_protocol = plugin; jabber_init_plugin(plugin); purple_prefs_remove("/plugins/prpl/jabber"); /* XXX - If any other plugin wants SASL this won't be good ... */ #ifdef HAVE_CYRUS_SASL #ifdef _WIN32 sasldir = g_build_filename(wpurple_install_dir(), "sasl2", NULL); sasl_set_path(SASL_PATH_TYPE_PLUGIN, sasldir); g_free(sasldir); /* Suppress error popups for failing to load sasl plugins */ old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS); #endif if ((ret = sasl_client_init(NULL)) != SASL_OK) { purple_debug_error("xmpp", "Error (%d) initializing SASL.\n", ret); } #ifdef _WIN32 /* Restore the original error mode */ SetErrorMode(old_error_mode); #endif #endif jabber_register_commands(); /* reverse order of unload_plugin */ jabber_iq_init(); jabber_caps_init(); /* PEP things should be init via jabber_pep_init, not here */ jabber_pep_init(); jabber_data_init(); jabber_bosh_init(); /* BEGIN SPICEBIRD CHANGES */ #if 0 #warning implement adding and retrieving own features via IPC API #endif /* END SPICEBIRD CHANGES */ jabber_ibb_init(); jabber_si_init(); purple_signal_connect(purple_get_core(), "uri-handler", plugin, PURPLE_CALLBACK(xmpp_uri_handler), NULL); }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); UNREFERENCED_PARAMETER(nCmdShow); SetDllDirectory(L""); ::OleInitialize(NULL); // we need some of the common controls INITCOMMONCONTROLSEX icex; icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_LINK_CLASS|ICC_LISTVIEW_CLASSES|ICC_PAGESCROLLER_CLASS |ICC_PROGRESS_CLASS|ICC_STANDARD_CLASSES|ICC_TAB_CLASSES|ICC_TREEVIEW_CLASSES |ICC_UPDOWN_CLASS|ICC_USEREX_CLASSES|ICC_WIN95_CLASSES; InitCommonControlsEx(&icex); apr_initialize(); setlocale(LC_ALL, ""); // to avoid that SASL will look for and load its plugin dlls all around the // system, we set the path here. // Note that SASL doesn't have to be initialized yet for this to work sasl_set_path(SASL_PATH_TYPE_PLUGIN, (LPSTR)(LPCSTR)CUnicodeUtils::StdGetUTF8(CAppUtils::GetAppDirectory()).c_str()); // first create a hidden window which serves as our main window for receiving // the window messages, starts the monitoring thread and handles the icon // in the tray area. MSG msg; msg.wParam = FALSE; HACCEL hAccelTable; hInst = hInstance; INITCOMMONCONTROLSEX used = { sizeof(INITCOMMONCONTROLSEX), ICC_BAR_CLASSES }; InitCommonControlsEx(&used); Snarl::SnarlInterface snarlIface; CCmdLineParser parser(lpCmdLine); if (parser.HasKey(_T("patchfile"))) { hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_CMVIEWER)); // in this case, we start another part of our application, not // the monitoring part. CDiffViewer viewer(hInst); if (parser.HasVal(_T("title"))) viewer.SetTitle(parser.GetVal(_T("title"))); if (viewer.RegisterAndCreateWindow()) { if (viewer.LoadFile(parser.GetVal(_T("patchfile")))) { ::ShowWindow(viewer.GetHWNDEdit(), SW_SHOW); ::SetFocus(viewer.GetHWNDEdit()); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(viewer, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } } } } else { //only one instance of this application part allowed g_mutex = ::CreateMutex(NULL, FALSE, APPNAME_MUTEX); if (g_mutex != NULL) { if ((::GetLastError()==ERROR_ALREADY_EXISTS)&&(!parser.HasKey(_T("task")))) { //an instance of this app is already running HWND hWnd = FindWindow(ResString(hInst, IDS_APP_TITLE), NULL); //try finding the running instance of this app if (hWnd) { UINT COMMITMONITOR_SHOWDLGMSG = RegisterWindowMessage(_T("CommitMonitor_ShowDlgMsg")); PostMessage(hWnd, COMMITMONITOR_SHOWDLGMSG ,0 ,0); //open the window of the already running app SetForegroundWindow(hWnd); //set the window to front } apr_terminate(); return FALSE; } } CHiddenWindow hiddenWindow(hInst); hAccelTable = LoadAccelerators(hInst, MAKEINTRESOURCE(IDC_COMMITMONITOR)); if (hiddenWindow.RegisterAndCreateWindow()) { if ((snarlIface.GetVersionEx() != Snarl::M_FAILED)&&(Snarl::SnarlInterface::GetSnarlWindow() != NULL)) { std::wstring imgPath = CAppUtils::GetAppDataDir()+L"\\CM.png"; if (CAppUtils::ExtractBinResource(_T("PNG"), IDB_COMMITMONITOR, imgPath)) { // register with Snarl snarlIface.RegisterApp(_T("CommitMonitor"), imgPath.c_str(), imgPath.c_str(), hiddenWindow); snarlIface.RegisterAlert(_T("CommitMonitor"), ALERTTYPE_NEWPROJECTS); snarlIface.RegisterAlert(_T("CommitMonitor"), ALERTTYPE_NEWCOMMITS); snarlIface.RegisterAlert(_T("CommitMonitor"), ALERTTYPE_FAILEDCONNECT); } } if (parser.HasKey(_T("task"))) { hiddenWindow.SetTask(true); } else if (!parser.HasKey(_T("hidden"))) { hiddenWindow.ShowDialog(); } // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(hiddenWindow, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } } if (!hiddenWindow.StopThread(2000)) { hiddenWindow.RemoveTrayIcon(); TerminateProcess(GetCurrentProcess(), 0); } } ::OleUninitialize(); sasl_done(); apr_terminate(); if ((snarlIface.GetVersionEx() != Snarl::M_FAILED)&&(Snarl::SnarlInterface::GetSnarlWindow() != NULL)) { // unregister with Snarl snarlIface.UnregisterApp(); } return (int) msg.wParam; }
XSASL_SERVER_IMPL *xsasl_cyrus_server_init(const char *unused_server_type, const char *path_info) { const char *myname = "xsasl_cyrus_server_init"; XSASL_SERVER_IMPL *xp; int sasl_status; #if SASL_VERSION_MAJOR >= 2 && (SASL_VERSION_MINOR >= 2 \ || (SASL_VERSION_MINOR == 1 && SASL_VERSION_STEP >= 19)) int sasl_major; int sasl_minor; int sasl_step; /* * DLL hell guard. */ sasl_version_info((const char **) 0, (const char **) 0, &sasl_major, &sasl_minor, &sasl_step, (int *) 0); if (sasl_major != SASL_VERSION_MAJOR #if 0 || sasl_minor != SASL_VERSION_MINOR || sasl_step != SASL_VERSION_STEP #endif ) { msg_warn("incorrect SASL library version. " "Postfix was built with include files from version %d.%d.%d, " "but the run-time library version is %d.%d.%d", SASL_VERSION_MAJOR, SASL_VERSION_MINOR, SASL_VERSION_STEP, sasl_major, sasl_minor, sasl_step); return (0); } #endif if (*var_cyrus_conf_path) { #ifdef SASL_PATH_TYPE_CONFIG /* Cyrus SASL 2.1.22 */ if (sasl_set_path(SASL_PATH_TYPE_CONFIG, var_cyrus_conf_path) != SASL_OK) msg_warn("failed to set Cyrus SASL configuration path: \"%s\"", var_cyrus_conf_path); #else msg_warn("%s is not empty, but setting the Cyrus SASL configuration " "path is not supported with SASL library version %d.%d.%d", VAR_CYRUS_CONF_PATH, SASL_VERSION_MAJOR, SASL_VERSION_MINOR, SASL_VERSION_STEP); #endif } /* * Initialize the library: load SASL plug-in routines, etc. */ if (msg_verbose) msg_info("%s: SASL config file is %s.conf", myname, path_info); if ((sasl_status = sasl_server_init(callbacks, path_info)) != SASL_OK) { msg_warn("SASL per-process initialization failed: %s", xsasl_cyrus_strerror(sasl_status)); return (0); } /* * Return a generic XSASL_SERVER_IMPL object. We don't need to extend it * with our own methods or data. */ xp = (XSASL_SERVER_IMPL *) mymalloc(sizeof(*xp)); xp->create = xsasl_cyrus_server_create; xp->done = xsasl_cyrus_server_done; return (xp); }